Question
· Feb 28, 2020

SQLCODE Error -400

I have a code block in a BPL.  I have the below SQL and code.  All variables have been declared and set.  When I run the SQL, if there are no values returned, I get 100 for the value of SQLCODE when I perform the FETCH, which is correct.  If values are returned, I get a -400 error when I perform the first FETCH.  I've investigated, but cannot find the reason for a -400 error.  Hoping someone out here understands this and knows what's wrong.


   &sql(DECLARE D1 CURSOR FOR SELECT A.SHIPMENTTRACKINGNO, A.SERIALNO, A.CDWACCNO, A.CDWINVOICENO, A.CDWORDERNO, A.CDWPARTNO INTO :context.ShipmentTrackingNo, :context.SerialNo, :context.CDWAccNo, :context.CDWInvoiceNo, :context.CDWOrderNo, :context.PartNo FROM CDWTRACKING."UCH.CDWTRACKING" as A WHERE CUSTOMERPO=:context.CurrentPO and CDWPartNO=:context.CurrentPartNo)
    &sql(OPEN D1)
    set context.C1 = SQLCODE
    &sql(FETCH D1)
    set context.C1 = context.C1_SQLCODE
    WHILE (SQLCODE = 0)
  {
    set context.test1 = context.test1_"SerialNo"_context.SerialNo
    &sql(FETCH D1)
  }
    set context.C1 = context.C1_SQLCODE
    &sql(CLOSE D1)

Discussion (2)0
Log in or sign up to continue