AS400, SQL and COBOL anomalies
25 pts.
0
Q:
AS400, SQL and COBOL anomalies
I coded an update query in COBOL and included COMMIT=NONE so the update could go through. When the COBOL program executed it returned nulls, and coalesced the value to the default. When the query was executed either through qmqry or on-line on the sql screen it worked fine and updated the field properly.

I also tried calling a cl program that executed the QMQRY from within the COBOL program and I also got bad results. When I called the CL from within another CL or called the CL program directly I got expected results.

Here is the query:

EXEC SQL UPDATE FILEA A SET A.ITMID = COALESCE((SELECT DISTINCT B.ITMID FROM FILEB B WHERE A.FLDA = B.FLDA AND A.FLDB = B.FLDB AND A.FLDC = B.FLDC),:NO-ITM) END-EXEC.



Software/Hardware used:
as400 cobol iseries embedded sql
ASKED: Sep 23 2009  5:31 PM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
6540 pts.
0
A:
 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0
  • AddThis Social Bookmark Button
Are you sure the library list is the same?
Is the COBOL program doing any overrides?
I'd do a CHGJOB LOG(4 00 *SECLVL) and run the COBOL program again.
Then check your joblog to see what shows up there.
Last Answered: Oct 28 2009  2:25 PM GMT by CharlieBrowne   6540 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

TomLiotta   8025 pts.  |   Sep 25 2009  1:33AM GMT

Hard to answer for multiple reasons. Please describe the COBOL — ILE or OPM? Is it a module in a larger program? What options were specified on the CRTxxx command(s)? What was the SET OPTION statement in the compile module/program? What PROCESS statement was used?

Also:

  • UPDATE FILEA A SET A.ITMID = COALESCE((SELECT DISTINCT B.ITMID FROM FILEB B WHERE A.FLDA = B.FLDA AND A.FLDB = B.FLDB AND A.FLDC = B.FLDC),:NO-ITM)

Since that statement contains a host variable — NO-ITM — it wouldn’t run in QMQRY nor in interactive SQL. You had to use a different UPDATE statement. What was it? And what is the COBOL definition of NO-ITM? (NO-ITM probably doesn’t matter, but it might help in understanding.)

Did the COBOL execution actually update rows causing A.ITMID to become null when it previously had a value or was A.ITMID already null?

 
0