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 > DB2 SQL Procedures in z/Os

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-30-09, 15:58
schintala schintala is offline
Registered User
 
Join Date: Apr 2005
Location: USA
Posts: 119
DB2 SQL Procedures in z/Os

Dear friends,

I am creating a SQL procedure in DB2 on z/Os and giving the syntax error though the SQL is correct. We are in Db2 V8. Does SQL procedures allowed to create on z/os? I heard some thing to use development center to create.
Any ideas. My sql is as follws here.

CREATE PROCEDURE DRUGLIST
( IN PHOSPNO CHAR(4)
,OUT PMNEMONIC CHAR(8)
,OUT PDRUGSTAT CHAR(1)
,OUT PDRUGNM CHAR(76)
,OUT PDURATION CHAR(2)
,OUT PFREQ CHAR(10)
,OUT PDOSE DECIMAL(5, 2)
,OUT PSQLCODE INTEGER
,OUT PSQLSTATE CHAR(5)
,OUT PSQLERRMC VARCHAR(250)
)
RESULT SETS 0
MODIFIES SQL DATA
EXTERNAL NAME DRUGLIST
NO DBINFO
WLM ENVIRONMENT TDB2SID1
STAY RESIDENT NO
COLLID ICVPC
PROGRAM TYPE MAIN
RUN OPTIONS 'TRAP(OFF),RPTOPTS(OFF)'
COMMIT ON RETURN NO
LANGUAGE SQL
P1: BEGIN
DECLARE SQLCODE INTEGER;
DECLARE SQLSTATE CHAR(5);
SELECT
MNEMONIC
,DRUGSTAT
,DRUGNM
,DURATION
,FREQ
,DOSE
INTO PMNEMONIC
,PDRUGSTAT
,PDRUGNM
,PDURATION
,PFREQ
,PDOSE
FROM IDVPCS01.ITORDSET
WHERE HOSPNO = PHOSPNO ;

SET PSQLCODE = SQLCODE ;
SET PSQLSTATE = SQLSTATE;
SET PSQLERRMC = 'ADIOS' ;
END P1
I got the following error. I tried to work around to remove the semi colon and it didn't work.
DSNT408I SQLCODE = -104, ERROR: ILLEGAL SYMBOL "<END-OF-STATEMENT>". SOME
SYMBOLS THAT MIGHT BE LEGAL ARE: ;
DSNT418I SQLSTATE = 42601 SQLSTATE RETURN CODE
Reply With Quote
  #2 (permalink)  
Old 03-30-09, 16:28
sujith_g sujith_g is offline
Registered User
 
Join Date: Mar 2009
Posts: 16
Are you using
END
@

as the statement terminator?
Reply With Quote
  #3 (permalink)  
Old 03-30-09, 16:56
schintala schintala is offline
Registered User
 
Join Date: Apr 2005
Location: USA
Posts: 119
Thank you for the reply.

I use this way for the SQL code

P1: BEGIN

Sql statements;

END P1
;

Should I use different way?

Thanks,
Srini
Reply With Quote
  #4 (permalink)  
Old 03-30-09, 17:01
sujith_g sujith_g is offline
Registered User
 
Join Date: Mar 2009
Posts: 16
Here is a layout for Stored procedure

CREATE PROCEDURE procedurename (IN tmp INTEGER)
P1: BEGIN
sql goes here
P1:END

@
Reply With Quote
  #5 (permalink)  
Old 03-31-09, 09:11
schintala schintala is offline
Registered User
 
Join Date: Apr 2005
Location: USA
Posts: 119
Thank you. I tried with your suggestion. It didn't work. Same issue. Looks like SQL procedures syntax different from cobol procedure definitions on z/os environment.
Reply With Quote
  #6 (permalink)  
Old 03-31-09, 13:26
schintala schintala is offline
Registered User
 
Join Date: Apr 2005
Location: USA
Posts: 119
It worked after removing the declare statements. Did this procedure create an entry in catalog tables like SYSIBM.SYSROUTINES/SYSPARMS tables. I did not see any entry in these tables after the SQL execution. I wonder where this procedure definition stores in catalog table for DB2 sql procedures?
Reply With Quote
  #7 (permalink)  
Old 03-31-09, 13:43
sujith_g sujith_g is offline
Registered User
 
Join Date: Mar 2009
Posts: 16
Not sure about DB2 z/Os. For DB2 UDB they are under application objects--> stored procedure
Reply With Quote
  #8 (permalink)  
Old 03-31-09, 15:07
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
On DB2 z/OS V8, you have no real LANGUAGE SQL procedures available yet. You need to create a job that precompiles the stored proc (into some host language) and then use that.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
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