Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
sql code 331 while calling Stored Procedure

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
Ashishpanpaliya

New User


Joined: 13 Oct 2017
Posts: 29
Location: India

PostPosted: Wed Aug 01, 2018 7:06 pm    Post subject: sql code 331 while calling Stored Procedure
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: 8747
Location: Welsh Wales

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

Try looking here

https://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

Senior Member


Joined: 21 Sep 2010
Posts: 2064
Location: NY,USA

PostPosted: Wed Aug 01, 2018 8:18 pm    Post subject:
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: 29
Location: India

PostPosted: Wed Aug 01, 2018 8:34 pm    Post subject:
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

Senior Member


Joined: 21 Sep 2010
Posts: 2064
Location: NY,USA

PostPosted: Wed Aug 01, 2018 8:42 pm    Post subject:
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: 29
Location: India

PostPosted: Thu Aug 02, 2018 9:48 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts calling java code(on mainframe from c... elixir1986 COBOL Programming 1 Fri Nov 30, 2018 1:57 am
No new posts Need advise in calling DFSORT from REXX ajithajt CLIST & REXX 9 Thu Nov 29, 2018 10:50 am
No new posts Code numeric format to display both '... Time2Live COBOL Programming 7 Wed Nov 21, 2018 10:20 pm
No new posts Will this code extract 1 byte from fi... pkmurali CLIST & REXX 8 Sat Nov 10, 2018 11:13 pm
No new posts Calling and updating SAS Macro variab... Yogesh Jaiswal All Other Mainframe Topics 7 Thu Oct 11, 2018 12:37 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us