Calling Oracle stored procedure with output parameter from SQL Server

后端 未结 2 487
半阙折子戏
半阙折子戏 2020-12-15 07:44

I have an Oracle linked server in SQL Server 2008 R2. I need to execute Oracle stored procedures (with output parameter in first, and input parameter in second procedure):

相关标签:
2条回答
  • 2020-12-15 08:17

    Use REF CURSOR and declare that cursor as an output variable in oracle. Using Ref Cursor you can retrieve result set from Oracle Stored procedure

    0 讨论(0)
  • 2020-12-15 08:21

    It should work like this:

    DECLARE @dateval DATETIME
    
    EXECUTE ('begin my1.spGetDate(?); end;', @dateval OUTPUT) AT ORA_DBLINK_NAME;
    
    EXECUTE ('begin my1.spDeleteOldRecords(?); end;', @dateval) AT ORA_DBLINK_NAME;
    

    If you have several parameters, it could look like this:

    EXECUTE ('begin my1.spProc(?,?,?,?); end;', @param_in_1, @param_in_2, @param_out_3 OUTPUT, @param_out_4 OUTPUT) AT DBLINK_NAME;
    
    0 讨论(0)
提交回复
热议问题