Home > Software design >  How do I compile an SQL Cobol with || operator?
How do I compile an SQL Cobol with || operator?

Time:12-15

I'm trying to compile an SQLCobol source on a As400 system containing a statement with || (as a concat operator).

Even if IBM DB2 rules admit the || operator, my program compilation fails. I don't know if there is a compilation parameter to set. Can anyone help me?

Example of my code:

EXEC SQL                                                    
  INSERT INTO TABLEB                           
    (SELECT FIELD1 || " " || FIELD2  
       FROM TABLEA)                                       
END-EXEC.                

                               

The compilation error is

Token | not valid

Thanks to everyone

CodePudding user response:

I guess this is a code page issue with your terminal setup. The pipe symbol | the compiler wants, may be the broken bar ¦, ot the exclamation point ! on your keyboard. Try either ¦, or ! and see if one of these is accepted.

CodePudding user response:

The | symbol is not one of the invariant characters in EBCDIC code pages.

You may be running into a translation issue or it may not even be available.

Best practice is to use the literal CONCAT operator.

EXEC SQL                                                    
  INSERT INTO TABLEB                           
    (SELECT FIELD1 concat ' ' concat FIELD2  
       FROM TABLEA)                                       
END-EXEC. 
  • Related