IBM i

 View Only
  • 1.  COBOL use JSON_TABLE syntax ERROR SQL0104

    Posted Fri April 29, 2022 09:02 AM
    My  COBOL embedded SQL statement as fllowing:
    EXEC SQL
    select name, street, city, state, postal
    into :name, :street,
    :city, :state, :postal
    from JSON_TABLE(systools.HTTPGETCLOB(:uri,
    :header),
    'lax $'
    COLUMNS (
    NAME VARCHAR(30) CCSID 937 PATH 'lax $.NAME',
    STREET VARCHAR(30) CCSID 937 PATH 'lax $.STREET',
    CITY VARCHAR(30) CCSID 937 PATH 'lax $.CITY',
    STATE CHAR(25) PATH 'lax $.STATE',
    POSTAL CHAR(5) PATH 'lax $.POSTAL'
    )
    ) x
    END-EXEC.
    and  got follwoing syntax checking error message
     Additional Message Information

    Message ID . . . . . . : SQL0104 Severity . . . . . . . : 30
    Message type . . . . . : Diagnostic

    Message . . . . : Token 'lax $.NAME' was not valid. Valid tokens:
    <HEXSTRING> <CHARSTRING> <GHEXSTRING> <GRAPHSTRING>.
    Cause . . . . . : A syntax error was detected at token 'lax $.NAME'. Token
    'lax $.NAME' is not a valid token. A partial list of valid tokens is
    <HEXSTRING> <CHARSTRING> <GHEXSTRING> <GRAPHSTRING>. This list assumes that
    the statement is correct up to the token. The error may be earlier in the
    statement, but the syntax of the statement appears to be valid up to this
    point.
    but the same embedded SQL statement syntax checking no error in RPGLE and compile to RPGLE program. 

    Current OS V7R2,
    The same COBOL SQL JSON_TABLE statement syntax checking error aslo occured in V7R3.

    is it COBOL compiler issue ?



    ------------------------------
    Vengoal Chang
    ------------------------------


  • 2.  RE: COBOL use JSON_TABLE syntax ERROR SQL0104

    IBM Champion
    Posted Mon May 02, 2022 11:11 AM
    Edited by Jon Paris Mon May 02, 2022 11:14 AM
    I don't think you should have the "lax" on all the individual references.  That is used to set the base path for the section so it should look more like:

    COLUMNS (
    NAME VARCHAR(30) CCSID 937 PATH '$.NAME',
    STREET VARCHAR(30) CCSID 937 PATH '$.STREET',
    ... etc
    )

    As you why it is accepted by RPG and not by COBOL I can't tell you - the SQL pre-compilers are different for the two languages although I wouldn't expect the SQL processing part to be different but ...

    ------------------------------
    Jon Paris
    ------------------------------



  • 3.  RE: COBOL use JSON_TABLE syntax ERROR SQL0104

    Posted Tue May 03, 2022 03:12 AM
    changed to PATH '$.NAME' and got SQL0104 at SEU syntax checking.

    ------------------------------
    Vengoal Chang
    ------------------------------