ผมเขียน ASP ดึงข้อมูลจาก AS/400 โดยวนลูปเช็คข้อมูลแล้วเกิด Error ตามด้านล่างนี้ครับ
Error Type:
IBMDA400 Command (0x80004005)
SQL0104: Token Y was not valid. Valid tokens: FOR WITH FETCH ORDER UNION EXCEPT OPTIMIZE. Cause . . . . . : A syntax error was detected at token Y. Token Y is not a valid token. A partial list of valid tokens is FOR WITH FETCH ORDER UNION EXCEPT OPTIMIZE. 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. Recovery . . . : Do one or more of the following and try the request again: -- Verify the SQL statement in the area of the token Y. Correct the statement. The error could be a missing comma or quotation mark, it could be a misspelled word, or it could be related to the order of clauses. -- If the error token is <END-OF-STATEMENT>, correct the SQL statement because it does not end with a valid clause.
/consumption/consump.asp, line 145
sql9 = "SELECT D_ITEMNO AS ITEMNO, D_TRANSD, D_TRANSM, D_TRANSY, D_QTRANS, D_PRICE, D_VENDOR , D_PORD_NBR, D_VENDINVC FROM RINVDLIB.RINVD"&mm&""&yyy&" , RINVDLIB.RITEM"&mm&""&yyy&" WHERE D_ITEMNO = I_ITEMNO AND D_PORD_STS = 'T' AND (D_TRANSCD = '10' OR D_TRANSCD = '11') AND NOT ( (I_ITEMCLAS = 'C' AND I_INVCNTRL = '2') OR (I_ITEMCLAS = 'T' AND I_INVCNTRL = '2') ) UNION ALL SELECT D_ITEMNO AS ITEMNO, D_TRANSD, D_TRANSM, D_TRANSY, D_QTRANS, D_PRICE, D_VENDOR, D_PORD_NBR , D_VENDINVC FROM RINVDLIB.RINVD"&mm&""&yyy&" WHERE D_ITEMNO NOT IN ( SELECT I_ITEMNO FROM RINVDLIB.RITEM"&mm&""&yyy&") ORDER BY D_TRANSY ASC, D_TRANSM ASC, D_TRANSD ASC, D_PORD_NBR ASC"
rs9.open sql9, conn6, 1, 3
' num_count = rs9.RecordCount
' response.write num_count
' response.end
Set rs8= Server.CreateObject("ADODB.Recordset") sql8 = "Select * FROM RITEM"&mm&""&yyy&" where I_ITEMNO = '"&ITEMNO1&"' ORDER BY I_ITEMNO"
rs8.open sql8, conn6, 1, 3
if not rs8.eof then
ITEMNME = rs8("I_ITEMNME")
else
ITEMNME = "-"
end if
Set rs7 = Server.CreateObject("ADODB.Recordset")
sql7 = "Select WKORNO, PONO from RINVDLIB.RIDVWO"&mm&""&yyy&" where PONO = '"&PORDNBR&"' order by PONO"
rs7.open sql7, conn6, 1, 3
if not rs7.eof then
WONO = rs7("WKORNO")
else
WONO = "No W/O"
end if