View previous topic :: View next topic |
Author |
Message |
mikeg Beginner
Joined: 25 Aug 2003 Posts: 12 Topics: 6
|
Posted: Tue Aug 26, 2003 1:56 pm Post subject: Return Code form a Stored Procedure |
|
|
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 |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12382 Topics: 75 Location: San Jose
|
Posted: Tue Aug 26, 2003 3:25 pm Post subject: |
|
|
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 |
|
 |
|
|