English 中文(简体)
利用Ank服务器功能中的Oracle数据
原标题:Using Oracle data in a SQL Server function

我是在......。

我需要从Oracle中提取数据,并在服务器中加以使用,储存代谢功能或(最好)微粒功能。

第一部分是建立一个储存的代用品,以检索Oracle的数据。

ALTER PROCEDURE [dbo].[spCCStatus]
@Param1 nvarchar(10),
@Param2 nvarchar(10)
AS

BEGIN
SET NOCOUNT ON;

DECLARE @sql_str nvarchar (300)
SET @sql_str =  select count(*) from openquery(myOracleDB,  + char(39) +  SELECT      Field1, Field2 FROM Table1 WHERE Field1 =  +char(39)+char(39) + @Param1+ char(39) + char(39) +   AND PERSON =  +char(39)+char(39)+ @Param2 +char(39)+char(39)+char(39)+ ) 
 EXEC (@sql_str)

 END

对上述间谍进行罚款。

How do I consume this in a view? Alternatively how do I convert this to a scalar valued function.

最佳回答

形成这样的观点:

CREATE VIEW MyView
AS
SELECT *
FROM OPENQUERY(myOracleDB,  SELECT Field1, Field2 FROM Table1 )

也就是说,包括以后将过滤的栏目。

之后,你可以发挥这样的作用:

CREATE FUNCTION fnCCStatus
  @Param1 nvarchar(10),
  @Param2 nvarchar(10)
AS BEGIN
  RETURN (SELECT COUNT(*)
          FROM MyView
          WHERE Field1 = @Param1
            AND Field2 = @Param2);
END;

http://www.ohchr.org。

因为你坚持要求将参数列入《环境倡议》......

  • 观点不能被贬低。

  • 职能必须使用<代码>。 INSERT EXEC,不允许(不是职能)。

因此,似乎你不得不继续采用所储存的程序办法。

但这可以得到加强。 你可以增加一个产出参数,将动态质询的结果作为计算值。 这样,你就能够用文字来利用《纲领》。 (But再次没有职能。) 您将获得与create相同的许可。 a 试图通过产出参数获得结果的功能,但running<>。 它将不使用这一信息: 仅履行职能,一些经过扩展的储存程序可在职能范围内执行。

您所储存的程序如何看待:

ALTER PROCEDURE [dbo].[spCCStatus]
@Param1 nvarchar(10),
@Param2 nvarchar(10),
@Count int OUTPUT
AS

BEGIN
SET NOCOUNT ON;

DECLARE @sql_str nvarchar (300);
DECLARE @result TABLE (cnt int);
SET @sql_str =  select count(*) from openquery(myOracleDB,  + char(39)
             +  SELECT Field1, Field2 FROM Table1 WHERE Field1 =  
             + char(39) + char(39) + @Param1 + char(39) + char(39) +   AND PERSON =  
             + char(39) + char(39) + @Param2 + char(39) + char(39) + char(39) +  ) 
INSERT INTO @result
EXEC (@sql_str);
SELECT @Count = cnt FROM @result;

END

在使用文字时,你需要一个变数,才能把结果退回到:

...
DECLARE @QueryResult int;
EXECUTE @Param1Value, @Param2Value, @QueryResult OUT;
...

<>UT>/>>(<>>>>>>> 关键词应为之提供,以便正确开展工作。

问题回答

暂无回答




相关问题
SQL Server database is not visible

I have installed ASP.NET application with database on our server. ASP.NET application created database using connection string below. The problem is that I do not see database in SQL Server Management ...

Most efficient way to store number 11.111 in SQL Server

What datatype is the most efficient to store a number such as 11.111. The numbers will have up 2 digits before the point and up to three after. Currently the column is a bigint , I am guessing that ...

表格和数据表

是否需要在提瓜表之后更新表格统计数据,还是自动更新?

Inconsistent Generate Change Script

I add a column of type tinyint and being set to not allow nulls in a table and generate the change scripts. The table has data in it at this time. The script has code that creates a temp table and ...

Performance of Sql subqueriesfunctions

I am currently working on a particularly complex use-case. Simplifying below :) First, a client record has a many-to-one relationship with a collection of services, that is, a single client may have ...

selecting one value out of an xml column

I have a particularly troublesome xml column to query data from. The schema is fixed by the Quebec Ministry of Revenue so "it is what it is" The important part of the query looks like this: with ...

Selecting records during recursive stored procedure

I ve got a content management system that contains a hierarchical structure of categories, with sub-categories subject to different ordering options at each level. Currently, that s retrieved by a (...