需要使用cobol\db2的hlp作业

5lwkijsr  于 2023-06-05  发布在  DB2
关注(0)|答案(1)|浏览(372)

我有一个程序,我需要读取表DB2.SMLC_RGR_PRCT_RCS,其中字段NR_SMLC_RGR_PRCT = I 01-NR-SMLC-RGR-PRC,将变量的值与字段进行比较,只有当它们匹配时才前进,但无论我使用什么命令或逻辑都不起作用,我已经使用了所有的选择选项,并尝试使用fetch循环,任何提示?注意:我将只留下我所引用的程序部分和数据

*----------------------------------------------------------*
    WORKING-STORAGE  SECTION.
  *----------------------------------------------------------*
   77  CTE-PROG                    PIC X(016)    VALUE
                                   '*** GPOP9450 ***'.
   77  CTE-VERS                    PIC X(006)    VALUE   'VRS001'.
   77  SBVERSAO                    PIC X(008)    VALUE   'SBVERSAO'.
   77  SBABEND                      PIC  X(07) VALUE 'SBABEND'.
  *----------------------------------------------------------*
  *--------------------CONTADORES----------------------------*
   01  GDA-FIM-ARQUIVO             PIC X(03).
   01  GDA-REGISTROS-LIDOS         PIC 9(18) VALUE ZEROS.
   01  GDA-REGISTROS-N-ENCONTRADOS PIC 9(18) VALUE ZEROS.
   01  GDA_REGISTROS_ENCONTRADOS   PIC S9(4) USAGE COMP.
   01  GDA_REG                     PIC S9(4) USAGE COMP.
  *-------------------------------------------------------------*
  *                    ARQUIVO DE ENTRADA

   01 WREG-ARQENTD.
       03 I01-NR-SMLC-RGR-PRCT           PIC S9(4) USAGE COMP.
       03 I01-CODIGO-USUARIO             PIC X(08) VALUE IS SPACES.
  *-------------------------------------------------------------*
  *                     ARQUIVO DE SAIDA 01

   01 WREG-ARQSAI-1.
       03 O001-NR-SMLC-RGR-PRCT          PIC 9(04) VALUE ZEROS.
       03 O001-CODIGO-USUARIO            PIC 9(08) VALUE IS ZEROS.
       03 O001-DATA-PESQUISA             PIC X(10) VALUE IS SPACES.
  *-------------------------------------------------------------*
  *                      ARQUIVO DE SAIDA 02
   01 WREG-ARQSAI-2.
       03 O002-NR-SMLC-RGR-PRCT          PIC S9(4) USAGE COMP.
       03 O002-NR_SMLC_RGR_PRCT          PIC S9(4) USAGE COMP.
       03 O002-CD_OGM_RCS_SMLC           PIC S9(4) USAGE COMP.
       03 O002-TX_SMLC_RGR_PRCT          PIC X(50) VALUE SPACES.
       03 O002-DT_INC_MVT_SMLC          PIC X(10) VALUE SPACES.
       03 O002-DT_FIM_MVT_SMLC          PIC X(18)  VALUE ZEROS.
       03 O002-DATA-ALTERACAO           PIC X(26)  VALUE SPACES.
  *-------------------------------------------------------------*
   LOCAL-STORAGE SECTION.
  *----------------------------------------------------------*
  *--------------------ARÉA SQL----------------------------*
       EXEC SQL
            INCLUDE SQLCA
       END-EXEC.
  *-------------------------------------------------------------*
   PROCEDURE DIVISION.
   000000-INICIO  SECTION.
  *-------------------------------------------------------------*
        CALL SBVERSAO USING CTE-PROG CTE-VERS.

        PERFORM 0001-ABRE-ARQUIVOS
        PERFORM 0002-LER-ARQUIVO UNTIL GDA-FIM-ARQUIVO EQUAL 'S'
        PERFORM 0006-GERA-ESTATISTICAS

        CLOSE  ARQENTRD
               ARQSAI1
               ARQSAI2.

        STOP RUN.

   000000-FIM. EXIT.

   0001-ABRE-ARQUIVOS            SECTION.

       OPEN INPUT  ARQENTRD
            OUTPUT ARQSAI1
                    ARQSAI2
           .

   0001-FIM. EXIT.

   0002-LER-ARQUIVO              SECTION.

        READ ARQENTRD AT END MOVE 'S' TO GDA-FIM-ARQUIVO
                      NOT AT END
                      ADD 1 TO GDA-REGISTROS-LIDOS
                      PERFORM 01-BUSCA-DB2

        .

   0002-FIM. EXIT.

   01-BUSCA-DB2                  SECTION.

        EXEC SQL
          SELECT *
           INTO :GDA_REG
           FROM DB2.SMLC_RGR_PRCT_RCS
           WHERE NR_SMLC_RGR_PRCT = :I01-NR-SMLC-RGR-PRCT
        END-EXEC

       IF SQLCODE = 0
          PERFORM 0005-GRAVA-ARQSAI-1
       ELSE
       IF SQLCODE > 0
             PERFORM CHAMA-ERRO-001
       END-IF

...

zxlwwiss

zxlwwiss1#

必须确保COBOL和DB2中的变量是等效的。在COBOL的主要版本中,主机变量必须嵌入到SQL语句中。
下面的链接可以帮助你了解你的程序中缺少了什么。
https://www.ibm.com/docs/en/db2-for-zos/12?topic=statements-equivalent-sql-cobol-data-types
https://www.ibm.com/docs/en/db2-for-zos/12?topic=statements-declaring-host-variables-indicator-variables-in-cobol
https://www.microfocus.com/documentation/server-express/sx20books/dbhost.htm
所提供的代码显示,您从DB2.SMLC_RGR_PRCT_RCS表中获取所有列,并将其放入主机变量GDA_REG中,该变量与I 01-NR-SMLC-RGR-PRCT的类型和长度相同。请随意编辑您的帖子并添加表定义,以便我们可以检查错误并提供具体说明。
我希望这对你有帮助。好好玩。

相关问题