gpt4 book ai didi

Error "end-of-file" in the declaration of a cursor(游标声明中出现错误“文件结尾”)

转载 作者:bug小助手 更新时间:2023-10-22 14:29:38 28 4
gpt4 key购买 nike



I am doing a PL/SQL where I initially declare a cursor and then work with these values. The problem is that, along the lines of A.FH_DESACTIVEDATE DESC; I get the following error:

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


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:

;

The mistake doesn't make sense to me. I've searched other pages, looked at other examples, and still can't find the reason why this error appears.

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


The PL/SQL is:

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;

...

I have executed the subqueries individually and the set and it works correctly, but not the cursor declaration. What is happening?

我已经分别执行了子查询和集合,它工作正常,但没有执行游标声明。发生了什么?


I have reviewed examples of other colleagues and the statement of their cursors is the same. I've searched for information from other queries on stack or other pages but I can't find this error exactly.

我已经回顾了其他同事的例子,他们的粗略陈述也是一样的。我已经在堆栈或其他页面上搜索了其他查询的信息,但我找不到确切的错误。


更多回答

Cannot replicate the issue fiddle. Are you sure that code produces that error?

无法复制问题fiddle。你确定代码会产生那个错误吗?

优秀答案推荐

There's nothing wrong with that piece of code.

那段代码没有错。


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.

This is code you're complaining about:

这是你抱怨的代码:


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>

So ... nope, nothing's wrong with it.

所以不,没什么问题。




On the other hand, you said

另一方面,你说



... along the lines of A.FH_DESACTIVEDATE ESCR;



There's no such line in code you posted. Are you sure that this code is to blame?

你发布的代码中没有这样的行。你确定这个代码是罪魁祸首吗?


更多回答

Sorry, the name ESCR was a mistake. It is already corrected in the description. On the other hand, I don't think there's an error in that statement either, but it still marks that line as an "end-of-file" error. Any ideas?

对不起,ESCR这个名字是个错误。说明中已对其进行了更正。另一方面,我认为该语句中也没有错误,但它仍然将该行标记为“文件结尾”错误。有什么想法吗?

Well, post your own SQL*Plus session which illustrates the problem.

好吧,发布您自己的SQL*Plus会话来说明这个问题。

I have also tried to execute the declaration of the cursor alone as you have done and I keep getting the same error. I'm using DBeaver, oracle 11g and encoding ISO-8859-1

我也尝试过像您所做的那样单独执行游标的声明,但我一直收到同样的错误。我使用的是DBeaver、oracle11g和编码ISO-8859-1

DBeaver. I don't use that tool, but just recently (a couple of days ago) another user had similar problems, reporting that code they wrote works OK in SQL*Plus, but fails in DBeaver. I don't claim that that's the fact here as well, but rings a bell.

DBeaver。我没有使用这个工具,但就在最近(几天前),另一位用户也遇到了类似的问题,报告说他们编写的代码在SQL*Plus中可以正常工作,但在DBeaver中失败了。我也不认为这是事实,但这敲响了警钟。

Ok, I'm going to try SQL Developer or something like that to see if it might be the problem. Thank you!

好的,我将尝试SQL Developer或类似的东西,看看它是否有问题。非常感谢。

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com