Page 1 of 1

How to display in SYSOUT?

Posted: Tue Jun 12, 2007 12:45 pm
by arrbee
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.

Posted: Tue Jun 12, 2007 1:21 pm
by dbzTHEdinosauer
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 .

Posted: Tue Jun 12, 2007 1:57 pm
by dbzTHEdinosauer
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.

Posted: Tue Jun 12, 2007 2:09 pm
by dbzTHEdinosauer
also, you need to check your sqlcode after every sql statement. I omitted the sqlcode check because I was lazy.

Posted: Fri Jun 15, 2007 12:59 pm
by arrbee
thanks for the details.