October 12, 2009 at 7:45 am
Hi Everyone,
Is it possible to call a DB2 stored procedure using a linked server? I've read a bunch of conflicting information out on the internet. Various posts have claimed it is not supported but then I came across a couple of posts which suggest it is possible. If it is possible..please provide me with a link to the information. Any help is appreciated!
Thanks
October 12, 2009 at 8:05 pm
Have you tried using the EXEC..AT feature?
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
November 2, 2012 at 3:13 pm
I know it's an old post but the following should help a lot.
http://www.mcpressonline.com/index2.php?option=com_content&do_pdf=1&id=1541
The keys to the magic appear in the following...
--
-- Create Linked Server using ODBC DSN "AS400"
--
sp_addlinkedserver
@server=N'DB2400',
@srvproduct=N'DB2 UDB for iSeries',
@provider=N'MSDASQL',
@datasrc=N'AS400',
@provstr='CMT=0;SYSTEM=as400.mycompany.com',
@catalog='S104X824'
go
--
-- Define the credentials that will be used to
-- access objects hosted by the Linked Server
--
sp_addlinkedsrvlogin @rmtsrvname=N'DB2400',
@useself='false',
@rmtuser=N'MyUser',
@rmtpassword='MyPassword'
go
--
-- RPC option is required for doing EXEC AT
--
EXEC sp_serveroption 'DB2400', 'rpc out', true
go
The biggest key here is that you must use the MSDASQL driver and you must enable "rpc out".
The article at the link also gives an example call to return a result set as follows... Obviously, the temp table must already exist but that's also covered in the article.
--
-- A DB2 stored procedure can be executed
--
Set @OrderID = 10249
Insert Into #tmpOrderHdr
Exec ('Call DATALIB.GetOrders (?)', @OrderID) AT DB2400
[font="Arial Black"]To be clear, I've not tried any of this, yet. Our infrastructure team is in the process of installing the correct MSDASQL driver.[/font]
--Jeff Moden
Change is inevitable... Change for the better is not.
November 5, 2012 at 11:53 am
Sweet. Really nice find, Jeff. This goes in my Favorites list... 🙂
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
May 22, 2015 at 6:56 am
I am newbie to linked server concept, I am looking for help to resolve my issue. Please suggest.
My requirement:
In DB2 data base I have a stored procedure and from SQL 2008 R2 using Linked server I need to be able to execute stored procedure. I am getting the error while I am trying to execute.
Created SP as below with db2admin user:
CREATE OR REPLACE PROCEDURE SP_MyStoredProcedure
LANGUAGE SQL
SPECIFIC SP_MyStoredProcedure
-- EXTERNAL ACTION
BEGIN
.......
END
select * from [MyDb2LinkedServer].[db2DB].[db2admin].TLS_MyDb2Table and I get the results, which means my linked server DB2 connectivity is fine.
Then while executing as below SP got the error
exec [MyDb2LinkedServer].[db2DB].[db2admin].SP_MyStoredProcedure
Error:
OLE DB provider "DB2OLEDB" for linked server "MyDb2LinkedServer" returned message "Routine "*rocedure"?SQL150518145704050?...erver"."SP_MyStoredProcedure"?*?4" (specific name "") is implemented with code in library or path "", function "" which cannot be accessed. Reason code: "". SQLSTATE: 42724, SQLCODE: -444".
Msg 7212, Level 17, State 1, Line 1
Could not execute procedure 'SP_MyStoredProcedure' on remote server 'MyDb2LinkedServer'.
Here in the error
specific name ""
library or path ""
function ""
Reason code: ""
all are empty, no much information is available.
Need help on this and how this can be resolved? Any help is appreciated.
Note:
"rpc", "rpc out" both options are true.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply