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 > Stored Procedure Retreive

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-17-07, 12:36
ASHOKJOSE ASHOKJOSE is offline
Registered User
 
Join Date: Jun 2007
Posts: 8
Stored Procedure Retreive

Hello,

I need an help with retrving results from a stored procedure, I need to correct the syntax which I am not able to get through

Given below are 3 commads, here 1) and 2) works fine, my problem is I need 3) to work fine too.

1) create table emp1 (empno int,SALARY int) (works fine)
2) CREATE PROCEDURE UPDATE_SALARY_10 (IN EMPLOYEE_NUMBER int,IN RATE int) LANGUAGE SQL MODIFIES SQL DATA UPDATE EMP1 SET SALARY = SALARY * RATE WHERE EMPNO = EMPLOYEE_NUMBER (works fine)
3) CREATE PROCEDURE dd (OUT result int) LANGUAGE SQL CONTAINS SQL select empno from emp1 (gives 104 error)

Can someone please help me here, I know its a syntax error but I am not able to get through it.

Thank you
Ashok
Reply With Quote
  #2 (permalink)  
Old 06-17-07, 15:26
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
Quote:
Originally Posted by ASHOKJOSE
CREATE PROCEDURE dd (OUT result int)
LANGUAGE SQL CONTAINS SQL select empno from emp1
Try the following instead:
Code:
CREATE PROCEDURE dd (OUT result int)
LANGUAGE SQL READS SQL DATA select empno into result from emp1
Also make sure that you don't get a -811 at runtime! (In this particular example, the table emp1 should have exactly one row.)
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/
Reply With Quote
  #3 (permalink)  
Old 06-17-07, 15:32
ASHOKJOSE ASHOKJOSE is offline
Registered User
 
Join Date: Jun 2007
Posts: 8
Smile Stored Procedure Retreive

Thank you very much Peter, it helped
This is the command I used and it helped

CREATE PROCEDURE dd (OUT result int) LANGUAGE SQL READS SQL DATA select empno into result from emp1 where empno=1
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