View previous topic :: View next topic |
Author |
Message |
vjpilp Beginner

Joined: 01 May 2004 Posts: 8 Topics: 2
|
Posted: Thu Jul 15, 2004 1:56 pm Post subject: NULL Indicators in DB2 stored proc for OUT Parameters |
|
|
Is it possible to send NULL values in an out parameter to a calling program when my stored proc is written in COBOL?
I tried this:
LINKAGE SECTION
10 LS-TEXT PIC X(10).
10 LS-TEXT-NI PIC S9(04) COMP.
If I set LS-TEXT-NI = -1 , the value received in the calling program(Java) is not NULL.
Is there a way to send back NULL is OUT parameter? |
|
Back to top |
|
 |
Bithead Advanced

Joined: 03 Jan 2003 Posts: 550 Topics: 23 Location: Michigan, USA
|
Posted: Thu Jul 15, 2004 2:07 pm Post subject: |
|
|
Try This
01 LS-TEXT.
49 LS-TEXT-NI PIC S9(04) COMP.
49 LS-TEXT PIC X(10).
Then move +0 to LS-TEXT-NI for NULL values. |
|
Back to top |
|
 |
SureshKumar Intermediate
Joined: 23 Jan 2003 Posts: 211 Topics: 21
|
Posted: Thu Jul 15, 2004 2:12 pm Post subject: |
|
|
Vipilp,
The answer is yes. You can send nulls. Look at how the stored procedure is defined. Something like PARAMETER STYLE GENERAL WITH NULLS
Moreover, if you have a group item its has to be defined at a 01 level. The null indicator acts on a given 01 level. example
01 LS-TEXT-1 PIC X(10).
01 LS-TEXT-2 PIC X(10).
01 LS-TEXT-3 PIC X(10).
01 NULL-INDICATORS.
10 LS-TEXT-NI-1 PIC S9(04) COMP.
10 LS-TEXT-NI-2 PIC S9(04) COMP.
10 LS-TEXT-NI-3 PIC S9(04) COMP. |
|
Back to top |
|
 |
vjpilp Beginner

Joined: 01 May 2004 Posts: 8 Topics: 2
|
Posted: Thu Jul 15, 2004 10:23 pm Post subject: |
|
|
The stored procedure is defined with parameter style as DB2SQL(can pass NULLS).
1. When I send NULL values from Java, I receive NULL indicators only for integers i.e S9(09) COMP. For other data types, I receive some garbage value. Am I doing something wrong here?
2. With parameter style definition, does it mean that my Java program alone can send NULLS or is it that my COBOL-DB2 program can send back NULLS to JAva? |
|
Back to top |
|
 |
SureshKumar Intermediate
Joined: 23 Jan 2003 Posts: 211 Topics: 21
|
Posted: Fri Jul 16, 2004 8:12 am Post subject: |
|
|
vipilp,
I am not sure if DB2SQL can receive nulls if 'GENERAL WITH NULLS ' is not specified. check the manuals. Moreover, for type DB2SQL the null indicators have to be defined at 01 level in the SP and the calling program myst explictly use them.
The good thing abour the SP's is that IBM has provided clear example of each type of parameter and how it can be used. There are different elements that needs to be looked at, so give it a try..refer to this manual if you have not done so..thanks
IBM Redbook : DB2 for z/OS Stored Procedures: Through the CALL and Beyond |
|
Back to top |
|
 |
|
|