COBOL

Expand all | Collapse all

CALL USING dynamic length item

  • 1.  CALL USING dynamic length item

    Posted 2 days ago
    Edited by Frank Swarbrick 2 days ago
    To successfully pass a dynamic length item to a called program you must specify the new "AS FIXED LENGTH" option on the CALL statement.  This works fine.  However the compiler gives no error if you omit the phrase, even though at run time the call (essentially) fails.  Seems like the compiler should not allow this behavior to compile "successfully".

    Also somewhat related.  The CICS co-processor does not give any "compile" error when an attempt is made to use a dynamic length item in an EXEC CICS statement, even though doing so is not supported.  And while I've not tested EXEC SQL, I imagine it has a similar issue.

    Speaking of which, is there anything in the works for CICS and DB2/SQL to support using dynamic length items?  I imagine there would have to be some sort of implicit conversion to/from fixed-length fields.

    ------------------------------
    Frank Swarbrick
    ------------------------------


  • 2.  RE: CALL USING dynamic length item

    Posted yesterday
    When you use a dynamic length variable as a host variable to hold the value of a Db2 VARCHAR, are you saying it does not work?

    ------------------------------
    Jon Butler
    ------------------------------



  • 3.  RE: CALL USING dynamic length item

    Posted yesterday
    Correct, it does not even compile.
    000013         001700 working-storage section.                                                  
    000014         001800 01  string-1                    pic x dynamic.                            
                                                                                                    
    000015         001900 01  string-80                   pic x(80).                                
    000016         002000 01  group-1.                                                              
    000017         002100     05                          pic x value quote.                        
                                                                                                    
    000018         002200     05  g-string                pic x dynamic length.                     
    000019         002300     05                          pic x value quote.                        
                                                                                                    
    000020         002400                                                                           
    000021         002500 procedure division.                                                       
    000022         002600     exec sql                                                              
                                                                                                    
    000022==> IGYPS0212-S SQL host variable reference "STRING-1" had invalid syntax or the          
                          referenced host variable was an invalid SQL variable type.  The statement 
                          was discarded.                                                            
                                                                                                    
    000023         002700         select 'This is a Db2 test'                                       
    000024         002800         into :string-1                                                    
    000025         002900         from sysibm.sysdummy1                                             
    000026         003000     end-exec                                                              ​


    ------------------------------
    Frank Swarbrick
    ------------------------------



  • 4.  RE: CALL USING dynamic length item

    Posted yesterday
    Bummer.  This would seem to be one place the DYNAMIC variables would be very useful, rather than the obtuse 49-level.

    ------------------------------
    Jon Butler
    ------------------------------