IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

sql code 331 while calling Stored Procedure


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Ashishpanpaliya

New User


Joined: 13 Oct 2017
Posts: 32
Location: India

PostPosted: Wed Aug 01, 2018 7:06 pm
Reply with quote

I have defined below table.

Code:
CREATE TABLE ORDERNEXT
(
NAME        CHAR(10)
,SURNAME    CHAR(10)
);


created below stored procedure in cobol.

Code:
LINKAGE SECTION.
01 NAME-IN                      PIC X(10).
01 SURNAME-OUT                  PIC X(10).
01 RETURN-CODE-OUT              PIC X(2).
*******************************************
PROCEDURE DIVISION USING NAME-IN
                        ,SURNAME-OUT
                        ,RETURN-CODE-OUT.
PROG-CONTROL                   SECTION.
    DISPLAY 'SP Started'.

    EXEC SQL
    SELECT   SURNAME
    INTO    :SURNAME-OUT
     FROM ORDERNEXT
     WHERE NAME          = :NAME-IN
    END-EXEC.


Also defined in database.

now I am calling above SP using another program as below but failing with SQL 331.

Code:
EXEC SQL
 CALL PROGRAM4
 (
 :NAME_IN
,:SURNAME_OUT
,:RETURN-CODE-OUT)
END-EXEC.


also copied other sql messages

Code:
SQLCAID  :SQLCA
SQLCABC  :0000000136
SQL CODE:000000331
SQLERRMC :3 1208 1140 16
SQLERRP  :DSNXROHB
SQLERRD1 :000000117
SQLERRD2 :000000000
SQLERRD3 :000000000
SQLERRD4 :000000001
SQLERRD5 :000000000
SQLERRD6 :000000000
SQLWARN  :
SQL STATE:22021
SQLEXT   :   22021

this last bit coded for you

Any help in this regard will be helpful.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8794
Location: Welsh Wales

PostPosted: Wed Aug 01, 2018 7:57 pm
Reply with quote

Try looking here

www.ibm.com/support/knowledgecenter/en/SSEPEK_11.0.0/codes/src/tpc/db2z_n.html
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2567
Location: NYC,USA

PostPosted: Wed Aug 01, 2018 8:18 pm
Reply with quote

What you have shown is just a COBOL Program, I hope you understand that. Where have you defined the SP ? Which catalog tables? Did you even know those table if you do it by yourself or did you even reach out to DBAs to define them first before even you execute it?
Back to top
View user's profile Send private message
Ashishpanpaliya

New User


Joined: 13 Oct 2017
Posts: 32
Location: India

PostPosted: Wed Aug 01, 2018 8:34 pm
Reply with quote

Quote:
Where have you defined the SP


I have defined SP using below SQL in spufi ...also verified entry in sysroutine and sysparameter tables.

Code:
CREATE  PROCEDURE PROGRAM4 (
IN NAME   CHAR(10)             
,OUT SURNAME CHAR(10)           
,OUT RETURN_CODE CHAR(2))                                               
 RESULT SETS 0                                                         
LANGUAGE COBOL                                                         
EXTERNAL NAME PROGRAM4                                                 
FENCED                                                                 
COLLID ASHISH1                                                         
WLM ENVIRONMENT DBCGENV                                               
RUN OPTIONS 'NOTEST(NONE,*,*,*)' ;
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2567
Location: NYC,USA

PostPosted: Wed Aug 01, 2018 8:42 pm
Reply with quote

Example COBOL stored procedure with a GENERAL linkage convention If this link don't help you then only DBA's can assist you what parameters to be used since they are site specific. Please reach out to them.
Back to top
View user's profile Send private message
Ashishpanpaliya

New User


Joined: 13 Oct 2017
Posts: 32
Location: India

PostPosted: Thu Aug 02, 2018 9:48 pm
Reply with quote

By using 'PARAMETER CCSID ASCII' while defining SP in DB solved the issue.

Thanks Everyone.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Execute step regardless of previous s... JCL & VSAM 2
No new posts Error 0C1 Reason Code 1 with branch i... PL/I & Assembler 3
No new posts Any examples of calling FTP from REXX? CLIST & REXX 1
No new posts JCL for replacing code in Cobol JCL & VSAM 7
No new posts Calling Assembler from REXX PL/I & Assembler 5
Search our Forums:

Back to Top