MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Return Code form a Stored Procedure

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
mikeg
Beginner


Joined: 25 Aug 2003
Posts: 12
Topics: 6

PostPosted: Tue Aug 26, 2003 1:56 pm    Post subject: Return Code form a Stored Procedure Reply with quote

I have been calling a Stored Procedure from a COBOL program and have been receiving a return code of 0. Which of course is bad, I want to get a +466. My stored procedure was getting a -180 (bad date format). How can my COBOL program get the stored procedures return code? and I would also like the SQLCA.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12382
Topics: 75
Location: San Jose

PostPosted: Tue Aug 26, 2003 3:25 pm    Post subject: Reply with quote

Mikeg,

You need to pass the error area from the stored procedure to main program.Look at the example below.

Main pgm
Code:

01  SP-STATUS                                PIC X(01).         
    88 SPS-DATA-FOUND                       VALUE 'F'.
    88 SPS-DATA-NOT-FOUND                   VALUE 'N'.
    88 SPS-DATA-DB2-ERROR                   VALUE 'D'.
    88 SPS-DATA-APPL-ERROR                  VALUE 'E'.

01  SP-MESSAGE-CALL.                                                   
    49  SPM-FILLER1                       PIC S9(04) COMP.         
    49  SPM-FILLER2                       PIC X(960).               
01  SP-MESSAGE REDEFINES SP-MESSAGE-CALL.                           
    05  SPM-MESSAGES-LEN                  PIC S9(04) COMP.         
    05  SPM-SQL-ERROR-MESSAGE.                                     
        10  SPM-SQL-MESSAGE-LINE          PIC X(80)  OCCURS 12     
                                          INDEXED BY SP-MSG-IDX.   

01  SP-IN-AREA                            PIC X(10).

01  SP-OUT-AREA.                                                 
    49  SPO-FILLER1                       PIC S9(04) COMP.     
    49  SPO-FILLER2                       PIC X(29179).       

CALL STORED-PROC   USING SP-IN-AREA     
                         SP-STATUS       
                         SP-MESSAGE-CALL
                         SP-OUT-AREA     

EVALUATE TRUE
         WHEN SPS-DATA-FOUND
               SUCCESSFUL DATA EXTRACT
         WHEN SPS-DATA-NOT-FOUND 
               NO DATA FOUND
         WHEN SPS-DATA-DB2-ERROR
              PERFORM VARYING SP-MSG-IDX FROM 1 BY 1             
                      UNTIL SP-MSG-IDX > 8 OR                       
                      SPM-SQL-MESSAGE-LINE(SP-MSG-IDX) = SPACES
               DISPLAY SPM-SQL-MESSAGE-LINE(SP-MSG-IDX)
         WHEN SPS-DATA-APPL-ERROR
              PERFORM ABEND
END-EVALUATE 


Stored procedure
Code:

PROCEDURE DIVISION USING SP-IN-AREA       
                         SP-STATUS       
                         SP-MESSAGE-CALL 
                         SP-OUT-AREA.
   


Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group