简体   繁体   English

从 SQL 服务器中的链接服务器上的存储过程获取返回值

[英]Get return value from stored procedure on linked server in SQL Server

I have a stored function on an Oracle DB, that I'm executing from a procedure in SQL Server.我在 Oracle 数据库上有一个存储的 function,我正在从 SQL 服务器中的过程执行。 The function in Oracle returns a boolean value. Oracle 中的 function 返回 boolean 值。 The trouble I'm having is getting that value once it's executed.我遇到的麻烦是一旦执行就获得了该值。

Here's the call:这是电话:

EXEC  ('DECLARE
            x boolean;
        BEGIN
            x := dba.ws_pack.truncate_table;
        END;'
) AT DBLINK;

Which works for executing the function and truncating the table.这适用于执行 function 并截断表格。

So any idea how I get the value of x, or how I can execute this and get the return value directly?那么知道如何获取 x 的值,或者如何执行它并直接获取返回值?

EXEC ('BEGIN ? := dba.ws_pack.truncate_table; END;', @ReturnValue ) AT DBLINK;

Here's what I got to work:这是我要工作的内容:

select @return_value = val from openquery(DBLINK, 'select dba.ws_pack.truncate_table val from dual');

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

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