String Statement Error



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

String Statement Error

Postby ajit mainframe » Fri Dec 10, 2010 5:48 pm

I have used string and delimiter to execute my sql query "drop table 'tablename'". Now it is showing something unexpected. the EBCDIC i got is like this:
"001FC4D9D6D740E3C1C2D3C54000C2F0F0F3F0F8F5F9C1C1C1C1C1C1" and when i decoded it , this is something like this "(NUL)IUSDROP TABLE (NUL)B0030859AAAAAA". Can someone tell me why and how it is taking such a junk value.

The code is something given below.

01 WS-TBL-STRING.                                           
   49 STRING-LEN          PIC S9(4)  USAGE COMP VALUE ZEROS.
   49 DROP-STRING         PIC X(100) VALUE SPACES.         
    .........................................................                                             
    .........................................................
    .........................................................
   COMPUTE STRING-LEN = 11 + LENGTH OF WS-TBL-NAME   
   STRING 'DROP TABLE ' DELIMITED BY SIZE,           
        WS-TBL-NAME DELIMITED BY SPACE             
   INTO    DROP-STRING                               
  EXEC SQL                                         
     SET CURRENT SQLID = 'TRGI32'                 
  END-EXEC                                         
  EXEC SQL                                         
  EXECUTE IMMEDIATE :WS-TBL-STRING                 
  END-EXEC
ajit mainframe
 
Posts: 5
Joined: Mon Oct 25, 2010 9:55 am
Has thanked: 0 time
Been thanked: 0 time

Re: String Statement Error

 

Re: String Statement Error

Postby dick scherrer » Sat Dec 11, 2010 2:40 am

Hello,

and when i decoded it , this is something like this "(NUL)IUSDROP TABLE (NUL)B0030859AAAAAA".
What did you use to "decode" this?

The hex posted looks mostly like what i would expect. . . Where did you get value into ws-table-name?

As an aside, you need to move spaces to the receiving field before executing the STRING.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post