Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_ORAgetversion

  No additional text.


Syntax


-- Name:
--          sp_ORAgetversion

-- Description:
--          Oracle logic to retrieve version of server

-- Security:
--          Internal
-- Requires Certificate signature for catalog access

-- Returns:
--          Version string

-- Owner:
--          

create procedure sys.sp_ORAgetversion
(
	@publisher	sysname,
	@version	sysname OUTPUT
)
as
begin
	DECLARE @publisher_dbms		sysname
	DECLARE @publisher_version	sysname
	DECLARE	@InsColumnList		nvarchar(2000)
	DECLARE	@SelectColumnList	nvarchar(2000)
	DECLARE	@publisher_id		int
	DECLARE @retcode			int

	SET @retcode = 0
	SET @version = NULL

	SET NOCOUNT ON

	SELECT @publisher_id = svr.srvid
	FROM   master.dbo.sysservers svr
	JOIN   msdb.dbo.MSdistpublishers dist ON svr.srvname = dist.name
	WHERE  UPPER(dist.name collate database_default) = UPPER(@publisher) collate database_default

	IF @publisher_id IS NULL
	BEGIN
        RAISERROR (14080, 11, -1, @publisher)
		RETURN (1)
	END

	-- Read cached version string
	SELECT	@version = version
	FROM	dbo.IHpublishers
	WHERE	publisher_id = @publisher_id

	-- If the cached version is NOT NULL, return it
	IF @version IS NOT NULL
	BEGIN
		RETURN (0)
	END

	-- If the cached version is NULL, obtain the version with a remote call to the publisher

	-- Define sp_ORAremotequery support table
	create table #hquery
	(
		seq	int identity(2,1),
		cmd	nvarchar(4000)
	)

	-- Define temp table
  	CREATE TABLE #version
	(
		version		nvarchar(64)
	)
	
	-- Set publisher DBMS and version
	SELECT	@publisher_dbms		= N'ORACLE',
			@publisher_version	= NULL

	-- populate a temp table with a list of table columns from the Oracle publisher
	SELECT @InsColumnList    = 'version'
	SELECT @SelectColumnList = 'VERSION'

	INSERT INTO #hquery(cmd) VALUES('SELECT VERSION')
	INSERT INTO #hquery(cmd) VALUES('FROM PRODUCT_COMPONENT_VERSION')
	INSERT INTO #hquery(cmd) VALUES('WHERE UPPER(PRODUCT) LIKE ''%ORACLE%''')
	
	EXEC @retcode = sp_ORAremotequery
					@Server				= @publisher,
					@SelectColumnList	= @SelectColumnList,
					@InsTable			= '#version',
					@InsColumnList		= @InsColumnList

	IF @@ERROR != 0 OR @retcode != 0
	BEGIN
		-- If remote query fails, default to version 9.2
		SELECT	@version = N'9.2'
	END
	ELSE
	BEGIN
		-- Update version tag
		SELECT	@version = version
		FROM	#version

		UPDATE	dbo.IHpublishers
		SET		version = v.version
		FROM	#version v,
				IHpublishers ihp
		WHERE	ihp.publisher_id = @publisher_id
	END

	DROP TABLE #version
	DROP TABLE #hquery

	RETURN (0)
END

 
Last revision 2008RTM
See also

  sp_IHgetversion (Procedure)
sp_MSdrop_replcom (Procedure)
       



News

  Query a named instance
Sybase+ASE+silent+install
SQL 2008 R2
Deprecated procedures in SQL2008
Reporting Services item-level role definitions
Create all your missing indexes
Converting datetime field
Start MSSQL Server Profiler at time
Replicating MSSQL Server views
Exploring Microsoft Sharepoint
The OLE DB provider "SQLNCLI10" for linked server indicates.
Mobile solar charger
Oracle to SQL Server replication
Cannot insert the value NULL into column
Undocumented Microsoft SQL Server 2008
VMware
Zoekmachine optimalisatie
SQL Servers hidden objects
FckEditor
Flash in Ajax
De hype die AJAX heet
Barcode scannen
MySQL; Gratis, makkelijk en snel!
PHP
sIFR; de combinatie tussen HTML en Flash