简体   繁体   English

如何用相同的编号编写程序 &SQL Server中的参数设置?

[英]How to write procedure with same no. of parameter in Oracle & SQL Server?

SQL Server stored procedure: SQL Server存储过程:

CREATE PROC proc1
AS
SELECT ename FROM employee

Oracle Server stored procedure: Oracle Server存储过程:

CREATE OR REPLACE PROCEDURE proc1
(
cv_1 IN OUT SYS_REFCURSOR
)
AS
BEGIN
OPEN cv_1 FOR
SELECT ename
FROM employee ;
END;

Is it possible to write this procedure in both Oracle & SQL Server with same number of parameter with same supported data type? 是否可以在Oracle和SQL Server中使用相同数量的参数和相同的受支持数据类型编写此过程?

If possible how? 如果可能的话如何? and so how to call from both oracle & SQL Server? 以及如何从oracle和SQL Server两者调用?

We do this all the time and it works great however our systems are based on ODBC using the ODBC "Call" syntax to invoke procedures. 我们一直在这样做,并且效果很好,但是我们的系统是基于ODBC的,使用ODBC“调用”语法来调用过程。 I believe this feature was added to the Oracle driver circa Oracle 10. 我相信此功能已添加到大约Oracle 10的Oracle驱动程序中。

For example: 例如:

{CALL proc1} or if proc1 has non ref cursor parameters {CALL proc1(parm1,parm2,parm3)} {CALL proc1}或proc1具有非引用游标参数{CALL proc1(parm1,parm2,parm3)}

Oracle driver automatically does what is necessary to convert ref cursor(s) into result set(s). Oracle驱动程序会自动执行将引用游标转换为结果集所需的操作。 I believe there is/was an ordering dependancy in that the cursor parameter(s) need to be positioned last after any normal input parameters other than that you can have the same code returning result sets (using exact same query string to call procedures between SQL Server and Oracle) 我相信存在/具有排序依赖性,因为除了可以具有相同的代码返回结果集(使用完全相同的查询字符串来调用SQL之间的过程)之外,游标参数需要在任何常规输入参数之后最后放置服务器和Oracle)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM