简体   繁体   中英

Can't run db2 Query?

I get the following error:

SQL0104 Token GCOMN was not valid. Valid tokens: FOR USE SKIP WAIT WITH FETCH LIMIT ORDER UNION EXCEPT OFFSET.

This is the parameterized query I'm trying to run:

SELECT
    CASE
    WHEN GCOMN = 82 THEN 'S040'
    WHEN GCOMN = 2 THEN 'S041'
    END as SalesOrgId,
    gcusn as BillToId,
    gshpn as ShipTo_Mapics,
    sapcusn as ShipTo_SAP
FROM YSHPEXT WHERE GCOMN= ?GCOMN AND GCUSN= ?GCUSN AND GSHPN= ?GSHPN

I know for a fact that "GCOMN" is a valid column name.

Any ideas would be appreciated.

Is this a typo - such strange expressions like ?COLUMN .
Try to prepare the following and bind the parameters appropriately.:

SELECT
    CASE
    WHEN GCOMN = 82 THEN 'S040'
    WHEN GCOMN = 2 THEN 'S041'
    END as SalesOrgId,
    gcusn as BillToId,
    gshpn as ShipTo_Mapics,
    sapcusn as ShipTo_SAP
FROM YSHPEXT 
WHERE GCOMN=? AND GCUSN=? AND GSHPN=?;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM