"How To" Guides for Microsoft SQL Server

Executing DB2 Stored Procedures with Output Parameters

In order to access the output parameters, the stored procedure must be called in this manner:

exec sp_serveroption 'db2link', 'rpc', 'true'
exec sp_serveroption 'db2link', 'rpc out', 'true'
declare @in1, @in2, @outvar as char(3)
set @in1 = 'ABC'
set @in2 = 'GHI'
exec ('call schema.procname(?,?,?)', @in1, 'DEF', @in2, @outvar output) at db2link
exec ('call location.schema.procname(?,?,?)', @in1, 'DEF', @in2, @outvar output) at db2link
select @outvar

The string passed to the exec command is a native call statement. The question marks are placeholders for the parameters, which are bound to the variables specified in the command.

Prev: DB2 via Linked Server Next: OpenQuery 

Home > Computers > Databases > SQL Server > Stored Procs. > DB2 Stored Proc.

Viewing mobile website page. Switch to WML or Full HTML