本文介绍了在获取结束时没有得到sqlcode 100的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个问题,我似乎找不到任何在线解决方案。


我在cobol程序中使用游标来获取一些数据。我知道一个

的事实,select应返回2行。获取的工作方式与我想要的时间相同,但是当我进行下一次获取时,

程序异常结束。


我的下一步是检查sqlcode 100,正如我所期望的那样,

但是我的程序甚至都没有进入这一步。


有什么想法吗?这是一些代码,如果它有帮助。


EXEC SQL

DECLARE ACH_SEARCH CURSOR

SELECT

A.INDVD_NAME,

D.FILE_CRT_DATE,

C.EFCTV_ENTRY_DATE,

A.TRNSC_CODE,

A.RCVNG_DFI_ID,

A.DFI_ACNT_ID,

A.AMT,

A.INDVD_ID,

C. CMPNY_DSCRT_TEXT,

A.TRACE_NMBR,

B.PYMNT_RLTD_TEXT,

A.DSCRT_DATA_CODE

FROM(((TPMNFLA B

RIGHT OUTER加入TPMNFBD A ON

A.TRACE_NMBR = B.TRACE_NMBR)

INNER JOIN TPMNFLB C ON

A.NACHA_SQN_NMBR = C.NACHA_SQN_NMBR AND

A.BATCH_NMBR = C.BATCH_NMBR)

INNER JOIN TPMNFLH D ON

C.NACHA_SQN_NMBR = D.NACHA_SQN_NMBR)

在哪里A.INDVD_NAME喜欢''ROSEL C GOMEZ''

结束-EXEC


PERFORM A8100 -FETCH-SEARCH THRU

A8100-FETCH-SEARCH-EXIT

直到88-DONE


EXEC SQL

F. ETCH ACH_SEARCH

INTO

:NFBD-INDVD-NAME,

:NFLH-FILE-CRT-DATE,

:NFLB-EFCTV-ENTRY-DATE,

:NFBD-TRNSC-CODE,

:NFBD-RCVNG-DFI-ID,

:NFBD-DFI-ACNT-ID,

:NFBD-AMT,

:NFBD-INDVD-ID,

:NFLB-CMPNY- DSCRT-TEXT,

:NFBD-TRACE-NMBR,

:WS-ADDENDA指标:ADIND,

:NFBD-DSCRT-DATA-代码

END-EXEC。


评估真实

当SQLCODE = 0

做东西

当SQLCODE = 100

SET 88-DONE TO TRUE


当SQLCODE< -900

设置DB2-SYS-ERROR为真

执行S9910-PROCESS-SQL-ERROR

THRU S9910-PROCESS-SQL-ERROR -EXIT

I''m having a problem that I can''t seem to find any solution for online.

I''m using a cursor in a cobol program to fetch some data. I know for a
fact that the select should return 2 rows. The fetch works as I would
expect it to on the 2 rows, but then when I do my next fetch, the
program ends abnormally.

My next step is to check for sqlcode 100, as I would expect it to be,
but my program never even gets to this step.

Any ideas? Here is some code, if it helps.

EXEC SQL
DECLARE ACH_SEARCH CURSOR FOR
SELECT
A.INDVD_NAME,
D.FILE_CRT_DATE,
C.EFCTV_ENTRY_DATE,
A.TRNSC_CODE,
A.RCVNG_DFI_ID,
A.DFI_ACNT_ID,
A.AMT,
A.INDVD_ID,
C.CMPNY_DSCRT_TEXT,
A.TRACE_NMBR,
B.PYMNT_RLTD_TEXT,
A.DSCRT_DATA_CODE
FROM (((TPMNFLA B
RIGHT OUTER JOIN TPMNFBD A ON
A.TRACE_NMBR = B.TRACE_NMBR)
INNER JOIN TPMNFLB C ON
A.NACHA_SQN_NMBR = C.NACHA_SQN_NMBR AND
A.BATCH_NMBR = C.BATCH_NMBR)
INNER JOIN TPMNFLH D ON
C.NACHA_SQN_NMBR = D.NACHA_SQN_NMBR)
WHERE A.INDVD_NAME LIKE ''ROSEL C GOMEZ ''
END-EXEC

PERFORM A8100-FETCH-SEARCH THRU
A8100-FETCH-SEARCH-EXIT
UNTIL 88-DONE

EXEC SQL
FETCH ACH_SEARCH
INTO
:NFBD-INDVD-NAME,
:NFLH-FILE-CRT-DATE,
:NFLB-EFCTV-ENTRY-DATE,
:NFBD-TRNSC-CODE,
:NFBD-RCVNG-DFI-ID,
:NFBD-DFI-ACNT-ID,
:NFBD-AMT,
:NFBD-INDVD-ID,
:NFLB-CMPNY-DSCRT-TEXT,
:NFBD-TRACE-NMBR,
:WS-ADDENDA INDICATOR :ADIND,
:NFBD-DSCRT-DATA-CODE
END-EXEC.

EVALUATE TRUE
WHEN SQLCODE = 0
do stuff
WHEN SQLCODE = 100
SET 88-DONE TO TRUE

WHEN SQLCODE < -900
SET DB2-SYS-ERROR TO TRUE
PERFORM S9910-PROCESS-SQL-ERROR
THRU S9910-PROCESS-SQL-ERROR-EXIT

推荐答案



如果你得到一个SQLCODE,例如-818,你的代码会发生什么?


Pete H

What happens in your code if you get a SQLCODE of, say, -818?

Pete H




或许比我以前的帖子更好的例子,-305?提示:

---------------------------------------- -------------------------------------------------- ----------------

"如果数据类型可以处理NULL,则应用程序必须提供NULL

指示符。否则,可能会发生错误。如果使用NULL指示符不是
,则返回SQLCODE -305(SQLSTATE 22002)。

--------------- -------------------------------------------------- ------------------------------------------


Pete H

Or perhaps a better example than my previous post, a -305? Hint:
----------------------------------------------------------------------------------------------------------
"If the data type can handle NULLs, the application must provide a NULL
indicator. Otherwise, an error may occur. If a NULL indicator is not
used, an SQLCODE -305 (SQLSTATE 22002) is returned.
-----------------------------------------------------------------------------------------------------------

Pete H




很难说出问题是什么,因为我看不到你所有的

代码,包括段落您的PERFORM中引用的名称

UNTIL。


您是否宣布了退出处理程序?


是你的工作存储部分的声明光标? (如果没有,那么

将它移到那里)。

It is hard to tell what the problem is because I can''t see all of your
code, inlcuding the paragraph names that are referenced in your PERFORM
UNTIL.

Do you have any exit handlers declared?

Is your declare cursor in your working storage section? (if not, then
move it there).


这篇关于在获取结束时没有得到sqlcode 100的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 10:48