Ask question on - DataBase Concepts, IBM Mainframe DB2, DB2/UDB, DB2 Tools, SQL , DB2 programming with languages like COBOL, PL1.
Moderators: Kalicharan , Moderator Group
arrbee
Active Member
Posts: 144 Joined: Fri Feb 24, 2006 11:33 am
Post
by arrbee » Tue Jun 12, 2007 12:45 pm
Hi,
I need to display the columns and their corresponding host-variables in SYSOUT for a COBOL-DB2 program.
How to do it?
Please find the code below:
Code: Select all
P0001-UNLOCK-BORSED SECTION.
EXEC SQL
UPDATE XYZ_IRTER
SET LOCKED_INDCTR = 'N'
VU_LAST_CHG_TIMSTM = CURRENT TIMESTAMP
WHERE VU_PRIXNK_KEY = :DCLVUK-BORSE.VU-PRIXNK-KEY
AND VUK_BORSE_NBR = :DCLVUK-BORSE.VUK-BORSE-NBR
END-EXEC
In the above shown code, I want to display the variables
VUK_BORSE_NBR & :DCLVUK-BORSE.VUK-ORDER-NBR . How to achieve it?
Please help.
TIA.
Arr Bee
-------------
?My joy in learning is partly that it enables me to teach? - Seneca(Roman philosopher, mid-1st century AD)
dbzTHEdinosauer
Moderator
Posts: 981 Joined: Mon Oct 02, 2006 8:31 pm
Post
by dbzTHEdinosauer » Tue Jun 12, 2007 1:21 pm
arrbee ,
This can not be a CICS program. A simple
DISPLAY statement will transfers the contents of each operand to the output device.
You can only DISPLAY host varibables; your SQL does not populate any host variables.
You can only use the DISPLAY statement before or after the SQL. DISPLAY is not part of SQL .
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.
dbzTHEdinosauer
Moderator
Posts: 981 Joined: Mon Oct 02, 2006 8:31 pm
Post
by dbzTHEdinosauer » Tue Jun 12, 2007 1:57 pm
arrbee ,
After a few minutes of thought:
Even though this is a COBOL question, the DISPLAY statement, this question does belong here, DB2, because you will need to add SQL to display the column contents which you want. One suggestion would be:
Code: Select all
P0001-UNLOCK-BORSED SECTION.
EXEC SQL
SET :WS-CURRENT-TIMESTAMP = CURRENT_TIMESTAMP
END-EXEC
EXEC SQL
UPDATE XYZ_IRTER
SET LOCKED_INDCTR = 'N' ,
VU_LAST_CHG_TIMSTM = :WS-CURRENT-TIMESTAMP
WHERE VU_PRIXNK_KEY = :DCLVUK-BORSE.VU-PRIXNK-KEY
AND VUK_BORSE_NBR = :DCLVUK-BORSE.VUK-BORSE-NBR
END-EXEC
EXEC SQL
SELECT VUK_ORDER_NBR
INTO :DCLVUK-BORSE.VUK_ORDER_NBR
FROM XYZ_IRTER
WHERE VU_PRIXNK_KEY = :DCLVUK-BORSE.VU-PRIXNK-KEY
AND VUK_BORSE_NBR = :DCLVUK-BORSE.VUK-BORSE-NBR
AND VU_LAST_CHG_TIMSTM = :WS-CURRENT-TIMESTAMP
AND LOCKED_INDCTR = 'N'
END-EXEC
DISPLAY 'Borse-nbr' VUK-BORSE-NBR IN DCLVUK-BORSE
DISPLAY 'Order-nbr' VUK_ORDER_NBR IN DCLVUK-BORSE
You will notice that I changed the current-timestamp logic and I believe you need to add a comma in your SET clause, as I have done.
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.
dbzTHEdinosauer
Moderator
Posts: 981 Joined: Mon Oct 02, 2006 8:31 pm
Post
by dbzTHEdinosauer » Tue Jun 12, 2007 2:09 pm
also, you need to check your sqlcode after every sql statement. I omitted the sqlcode check because I was lazy.
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.
arrbee
Active Member
Posts: 144 Joined: Fri Feb 24, 2006 11:33 am
Post
by arrbee » Fri Jun 15, 2007 12:59 pm
thanks for the details.
Arr Bee
-------------
?My joy in learning is partly that it enables me to teach? - Seneca(Roman philosopher, mid-1st century AD)
Free tutorials from mainframegurukul
JCL Tutorial Covers all important JCL concepts.
Cobol Tutorial This tutorials covers all Cobol Topics from STRING to COMP-3.
DB2 Tutorial DB2 Tutorial focuses on DB2 COBOL Programming.
SORT Tutorial This Tutorial covers all important aspects of DFSORT with examples
CICS Tutorial This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Mainframe Interview questions
Mainframe Tools and others