游标声明中出现“文件结束”错误

问题描述 投票:0回答:1

我正在做一个 PL/SQL,我最初声明一个游标,然后使用这些值。问题是,按照 A.FH_DESACTIVEDATE ESCR; 的思路;我收到以下错误:

SQL Error [6550] [65000]: ORA-06550: línea 27, columna 29:
PLS-00103: Se ha encontrado el símbolo "end-of-file" cuando se esperaba uno de los siguientes:

   ;

这个错误对我来说没有意义。我搜索了其他页面,查看了其他示例,仍然找不到出现此错误的原因。

PL/SQL 是:

DECLARE
    CURSOR cursor_centre IS
        SELECT
            A.ID_CENTRE,
            A.TX_NAME,
            CASE WHEN A.FH_DESACTIVEDATE IS NOT NULL THEN 1 ELSE 0 END desactiveDate,
            A.NU_FKGROUP
        FROM
            CENTRE A
        INNER JOIN (
            SELECT
                FU_WITHOUTACCENT(REPLACE(TX_NAME, '.', '')) AS normalized_name,
                NU_FKORGANIZATION
            FROM
                CENTRE
            GROUP BY
                FU_WITHOUTACCENT(REPLACE(TX_NAME, '.', '')),
                NU_FKORGANIZATION
            HAVING
                COUNT(*) > 1
        ) B ON
            FU_WITHOUTACCENT(REPLACE(A.TX_NAME, '.', '')) = B.normalized_name
            AND A.NU_FKORGANIZATION = B.NU_FKORGANIZATION
        ORDER BY
            A.TX_NAME DESC,
            A.NU_FKGROUP ASC,
            A.FH_DESACTIVEDATE DESC;
        
    c_id_centre NUMBER;
    c_name VARCHAR2(255);
    c_desactive_date NUMBER;
    c_group NUMBER;

...

我已经单独执行了子查询和集合并且它工作正常,但不是游标声明。发生什么事了?

我查看了其他同事的例子,他们的光标的说法是一样的。我已经从堆栈或其他页面上的其他查询中搜索了信息,但我无法准确找到此错误。

plsql oracle11g
1个回答
0
投票

那段代码没有任何问题。

Sample table and function (as you didn't post them), just to make anonymous block compile:

SQL> CREATE TABLE centre
  2  (
  3     id_centre           NUMBER,
  4     tx_name             VARCHAR2 (10),
  5     fh_desactivedate    DATE,
  6     nu_fkgroup          NUMBER,
  7     nu_fkorganization   VARCHAR2 (10)
  8  );

Table created.

SQL> CREATE OR REPLACE FUNCTION fu_withoutaccent (par_tx_name IN centre.tx_name%TYPE)
  2     RETURN centre.tx_name%TYPE
  3  IS
  4  BEGIN
  5     RETURN NULL;
  6  END;
  7  /

Function created.

这是您抱怨的代码:

SQL> DECLARE
  2     CURSOR cursor_centre IS
  3          SELECT a.id_centre,
  4                 a.tx_name,
  5                 CASE WHEN a.fh_desactivedate IS NOT NULL THEN 1 ELSE 0 END desactivedate,
  6                 a.nu_fkgroup
  7            FROM centre a
  8                 INNER JOIN
  9                 (  SELECT fu_withoutaccent (REPLACE (tx_name, '.', '')) AS normalized_name,
 10                           nu_fkorganization
 11                      FROM centre
 12                  GROUP BY fu_withoutaccent (REPLACE (tx_name, '.', '')), nu_fkorganization
 13                    HAVING COUNT (*) > 1) b
 14                    ON     fu_withoutaccent (REPLACE (a.tx_name, '.', '')) =
 15                           b.normalized_name
 16                       AND a.nu_fkorganization = b.nu_fkorganization
 17        ORDER BY a.tx_name DESC, a.nu_fkgroup ASC, a.fh_desactivedate DESC;
 18
 19     c_id_centre       NUMBER;
 20     c_name            VARCHAR2 (255);
 21     c_desactive_date  NUMBER;
 22     c_group           NUMBER;
 23  BEGIN
 24     NULL;
 25  END;
 26  /

PL/SQL procedure successfully completed.

SQL>

所以...不,没有什么问题。


另一方面,你说

...沿着A.FH_DESACTIVEDATE ESCR;

您发布的代码中没有这样的行。您确定是这段代码造成的吗?

© www.soinside.com 2019 - 2024. All rights reserved.