Can you confirm if you have successfully executed an oracle stored procedure from sql server using the open query function. If yes, How? because I am having problems executing stored procedures with arguments using the OPENQUERY Function.
Oracle – executed an oracle stored procedure from sql server using the open query function
oraclesql-server-2005tsql
Related Topic
- Sql – How to limit the number of rows returned by an Oracle query after ordering
- Sql – Insert results of a stored procedure into a temporary table
- SQL update query using joins
- Sql – Function vs. Stored Procedure in SQL Server
- Oracle – How to execute an oracle stored procedure
- Sql – How to UPDATE from a SELECT in SQL Server
- Sql – Oracle SQL: Update a table with data from another table
- C# – How to pass an array into a SQL Server stored procedure
Best Answer
Finally tracked down a few solutions – the key to the problem (for us) is that by default RPCs are disabled for linked servers. The parameters for Rpc, Rpc Out, and Use Remote Collation need to be set to true. More info:
http://blog.sqlauthority.com/2007/10/18/sql-server-2005-fix-error-msg-7411-level-16-state-1-server-is-not-configured-for-rpc/
The solution you use will depend upon the procedure output requirements. The first example returns an output value. The second example no output values are returned (data is collected in a subsequent query).
Example 1
The procedure T2T_collect_all has two input parameters (start and end dates) and one output parameter (row count).
DECLARE @l_i_parameter1 varchar(10)
DECLARE @l_i_parameter2 varchar(10)
DECLARE @l_i_parameter3 varchar(10)
DECLARE @l_i_parameter4 varchar(10)
DECLARE @l_o_parameter1 integer
SET @l_i_parameter1 = '2009/10/01'
SET @l_i_parameter2 = 'yyyy/mm/dd'
SET @l_i_parameter3 = '2009/12/31'
SET @l_i_parameter4 = 'yyyy/mm/dd'
SET @l_o_parameter1 = 0
EXECUTE ( 'begin T2T_collect_all(to_date(?, ?), to_date(?, ?), ? ); end;',
) AT ORA_DB;
More Info: http://blogs.msdn.com/joaquinv/archive/2008/10/23/execute-oracle-stored-procedure-in-sql-server.aspx
Example 2a
The procedure T2T_collect_allx has only two input parameters (start and end dates).
EXECUTE ('begin T2T_collect_allx (SYSDATE - 40, SYSDATE); end;') ORA_DB;
Example 2b
SELECT * FROM OPENQUERY(ORA_DB, 'begin T2T_collect_allx (SYSDATE - 40, SYSDATE ); end;')