Page 1 of 1

String Statement Error

PostPosted: Fri Dec 10, 2010 5:48 pm
by ajit mainframe
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

Re: String Statement Error

PostPosted: Sat Dec 11, 2010 2:40 am
by dick scherrer
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.