If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > SQL Server OPENQUERY to call DB2 Stored Procedure

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-27-10, 14:36
waiting waiting is offline
Registered User
 
Join Date: Oct 2010
Posts: 4
SQL Server OPENQUERY to call DB2 Stored Procedure

Hi, new here, and new to db2. I'm pretty much a lightweight on DB anyway, but we've been using Informix for the last 13 years and are attempting a migration to DB2.

I've rewritten all my stored procedures and views for DB2 and they seem to all work great, so long as I'm executing them on the host server.

However, what I really need is to execute these from SQL server via a linked server. The SQL server admin has installed a OLE DB linked server, as he had for the Informix server, and it works great for SELECT queries, but not for stored procedures.

For example, this works fine:
Code:
SELECT * FROM OPENQUERY (DB2_TEST, 'SELECT * FROM Lawson.CuCodes;')
I can execute the procedure from the command prompt on the DB2 server no problem:
Code:
$ db2 "call Lawson.NextCheck('19' , ?)"

  Value of output parameters
  --------------------------
  Parameter Name  : CHECKNBR
  Parameter Value : 15835865

  Return Status = 0
However, if I attempt to call it from the openquery it returns and error:
Code:
SELECT * FROM OPENQUERY (DB2_TEST, 'CALL Lawson.NextCheck ( ''19'' , ? )') 

Msg 7357, Level 16, State 2, Line 1
Cannot process the object "CALL Lawson.NextCheck ( '19' , ? )". The OLE DB provider "IBMDADB2.DB2COPY1" for linked server "DB2_TEST" indicates that either the object has no columns or the current user does not have permissions on that object.
I've tried testing the OLE DB connection using the DB2 owner's permissions, but that didn't help.

Is this an easy fix?

64 bit DB2 v9.1.0.7 fix pack 7
SQLServer 2005 sp3
IBM OLE DB driver v9.7

Last edited by waiting; 10-27-10 at 14:55. Reason: Added version info
Reply With Quote
  #2 (permalink)  
Old 10-27-10, 15:14
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
What do you get when you try:
Code:
EXECUTE DB2_TEST..Lawson.NextCheck '19', @retval
-PatP
__________________
In theory, theory and practice are identical. In practice, theory and practice are unrelated.
Reply With Quote
  #3 (permalink)  
Old 10-27-10, 17:22
waiting waiting is offline
Registered User
 
Join Date: Oct 2010
Posts: 4
Code:
DECLARE @retval INTEGER
EXECUTE DB2_TEST..Lawson.NextCheck '19', @retval

OLE DB provider "IBMDADB2.DB2COPY1" for linked server "DB2_TEST" returned message "[DB2/HP64] SQL0440N  No authorized routine named "Lawson.NextCheck" of type "PROCEDURE" having compatible arguments was found.  SQLSTATE=42884
".
Msg 7212, Level 17, State 1, Line 2
Could not execute procedure 'NextCheck' on remote server 'DB2_TEST'.
And what confuses me about that is that I can call it successfully from the DB2 prompt, and my OPENQUERY SELECT queries work great too.
Reply With Quote
  #4 (permalink)  
Old 10-28-10, 11:52
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
Based on that error message, the odds are very good that you aren't running Version 3 of the Microsoft DB2 OLE DB driver. Earlier versions of the OLE DB driver don't support stored procedures in DB/2.

-PatP
__________________
In theory, theory and practice are identical. In practice, theory and practice are unrelated.
Reply With Quote
  #5 (permalink)  
Old 10-28-10, 13:04
waiting waiting is offline
Registered User
 
Join Date: Oct 2010
Posts: 4
We are actually using IBM's DB2 OLE driver, v9.7
Reply With Quote
  #6 (permalink)  
Old 10-29-10, 13:10
waiting waiting is offline
Registered User
 
Join Date: Oct 2010
Posts: 4
I'm always amazed that these kinda questions are so hard to get any good information on. I've googled and googled, and I've posted it here. I would imagine that we're not the only ones in the world doing this. In fact, it seems like it'd be pretty routine.
Reply With Quote
  #7 (permalink)  
Old 10-29-10, 13:28
Marcus_A Marcus_A is online now
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,198
I would open a PMR with IBM software support.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On