必须声明 SQL 标识符,即使已经声明
Posted
技术标签:
【中文标题】必须声明 SQL 标识符,即使已经声明【英文标题】:SQL identifier must be declared even declared already 【发布时间】:2017-09-29 03:30:50 【问题描述】:我正在运行附加的查询,但出现错误
错误(1,41):PLS-00201:必须声明标识符“TABLE_OUTPUT”。
我该如何解决这个问题?我已经在这里和那里更换和改变了,但是......应该没问题吧?
检查参数,我确定我已经输入了正确的类型和匹配...
谢谢!
create OR REPLACE procedure proc_gen_data (TBL_OUTPUT OUT TABLE_OUTPUT)
is
TYPE REC_OUTPUT IS RECORD(
eorder_date DATE,
entity_bic11 VARCHAR2(20),
entity_bic11 VARCHAR2(20),
ACCOUNT VARCHAR2(100),
COVERED_BY VARCHAR2(20),
ENTITIES_PRIORITIES VARCHAR2(1),
TASK_PRIORITY VARCHAR2(5),
folder_published NUMBER,
NEW_STATUS VARCHAR2(10)
);
TYPE TABLE_OUTPUT IS TABLE OF REC_OUTPUT;
LC_SELECT SYS_REFCURSOR;
LR_DETAILS TABLE_OUTPUT;
begin
OPEN LC_SELECT FOR
select t2.EORDER_DATE "EORDER DATE", t1.bic11 "ENTITY BIC11", t2.ACCOUNT, t2.covered_by "COVERED BY", t2.entities_priorities "ENTITIES PRIORITY", t1.top_priority "TASK PRIORITY", t2.folder_published "FOLDERS PUBLISHED", T2.NEW_STATUS "NEW STATUS"
from
(select s.entity_group_name entity_name, s.bic11 bic11,
--to_char(MAX(IOCUPDATED),'DD-MON-YYYY') "IOC_LAST_UPDATE",
--to_char(MAX(OMSUPDATED),'DD-MON-YYYY') "OMS_LAST_UPDATE",
--to_char(MAX(TOBUPDATED),'DD-MON-YYYY') "TOB_LAST_UPDATE",
--to_char(MAX(COMUPDATED),'DD-MON-YYYY') "COM_LAST_UPDATE",
--(MAX(TAXUPDATED),'DD-MON-YYYY') "TAX_LAST_UPDATE",
CASE
WHEN MAX(IOCUPDATED) >= MAX(OMSUPDATED) AND MAX(IOCUPDATED) >= MAX(TOBUPDATED) AND MAX(IOCUPDATED) >= MAX(COMUPDATED) AND MAX(IOCUPDATED) >= MAX(TAXUPDATED) THEN 'IOC'
WHEN MAX(OMSUPDATED) >= MAX(IOCUPDATED) AND MAX(OMSUPDATED) >= MAX(TOBUPDATED) AND MAX(OMSUPDATED) >= MAX(COMUPDATED) AND MAX(OMSUPDATED) >= MAX(TAXUPDATED) THEN 'OMS'
WHEN MAX(TOBUPDATED) >= MAX(IOCUPDATED) AND MAX(TOBUPDATED) >= MAX(OMSUPDATED) AND MAX(TOBUPDATED) >= MAX(COMUPDATED) AND MAX(TOBUPDATED) >= MAX(TAXUPDATED) THEN 'TOB'
WHEN MAX(COMUPDATED) >= MAX(IOCUPDATED) AND MAX(COMUPDATED) >= MAX(OMSUPDATED) AND MAX(COMUPDATED) >= MAX(TOBUPDATED) AND MAX(COMUPDATED) >= MAX(TAXUPDATED) THEN 'COM'
WHEN MAX(TAXUPDATED) >= MAX(IOCUPDATED) AND MAX(TAXUPDATED) >= MAX(OMSUPDATED) AND MAX(TAXUPDATED) >= MAX(TOBUPDATED) AND MAX(TAXUPDATED) >= MAX(COMUPDATED) THEN 'TAX'
ELSE 'IOC'
END AS TOP_PRIORITY
from
(
select egr.name entity_group_name, decode(e.office_type,'GH',e.legal_name_lei,e.institution_name ) name, e.bic11,
decode(cat.acronym,'IOC',decode(initiated_by_swift,'N','C','S'),null) IOC,
decode(cat.acronym,'IOC',fi.creation_date,null) IOCCREATED,
decode(cat.acronym,'IOC',fis.update_date,null) IOCUPDATED,
decode(cat.acronym,'OMS',decode(initiated_by_swift,'N','C','S'),null) OMS,
decode(cat.acronym,'OMS',fi.creation_date,null) OMSCREATED,
decode(cat.acronym,'OMS',fis.update_date,null) OMSUPDATED,
decode(cat.acronym,'TOB',decode(initiated_by_swift,'N','C','S'),null) TOB,
decode(cat.acronym,'TOB',fi.creation_date,null) TOBCREATED,
decode(cat.acronym,'TOB',fis.update_date,null) TOBUPDATED,
decode(cat.acronym,'COM',decode(initiated_by_swift,'N','C','S'),null) COM,
decode(cat.acronym,'COM',fi.creation_date,null) COMCREATED,
decode(cat.acronym,'COM',fis.update_date,null) COMUPDATED,
decode(cat.acronym,'TAX',decode(initiated_by_swift,'N','C','S'),null) TAX,
decode(cat.acronym,'TAX',fi.creation_date,null) TAXCREATED,
decode(cat.acronym,'TAX',fis.update_date,NULL) TAXUPDATED,
1 TOTAL
from entity_groups egr, entities e, folders f, folder_items fi, categories cat, folder_item_snapshots fis
where fi.fold_id=f.id
and f.enti_id =e.id
and e.engr_id=egr.id
and f.cate_id=cat.id
-- and fi.status!='PUBLISHED'
and fi.id =f.foit_rece_id
and fis.foit_id=fi.id
and fi.active_snap_id=fis.id
) s
group by s.entity_group_name, s.name, s.bic11
order by s.entity_group_name, s.bic11) t1
left join
--STATUS REPORT
(select to_char(creation_date, 'DD-Mon-RR') EORDER_DATE, bic11 "ENTITY_BIC11", institution_name ACCOUNT, covered COVERED_BY,
CASE WHEN nvl(total,0)=5 THEN '-'
WHEN nvl(total,0)=4 THEN 'HIGH'
WHEN nvl(total,0)=3 THEN 'MEDIUM'
WHEN nvl(total,0)=2 THEN 'LOW'
WHEN nvl(total,0)=1 THEN 'LOW'
WHEN nvl(total,0)=0 THEN 'LOW'
END AS ENTITIES_PRIORITIES,
nvl(total,0) FOLDER_PUBLISHED,
CASE WHEN nvl(total,0)=5 THEN 'COMPLETE'
WHEN nvl(total,0)=4 THEN 'FOLLOW UP ONGOING'
WHEN nvl(total,0)=3 THEN 'FOLLOW UP ONGOING'
WHEN nvl(total,0)=2 THEN 'FOLLOW UP ONGOING'
WHEN nvl(total,0)=1 THEN 'FOLLOW UP ONGOING'
END AS NEW_STATUS
from (
select creation_date, bic11, name, institution_name, covered, entity_group_name, sum(IOC) IOC, sum(OMS) OMS, sum(TOB) TOB, sum(COM) COM, sum(TAX) TAX, sum(total) TOTAL from
(
select e.creation_date, e.bic11, e.name, e.institution_name, E.covered, egr.name entity_group_name, decode(cat.acronym,'IOC',1,0) IOC, decode(cat.acronym,'OMS',1,0) OMS, decode(cat.acronym,'TOB',1,0) TOB, decode(cat.acronym,'COM',1,0) COM, decode(cat.acronym,'TAX',1,0) TAX, 1 total
from entity_groups egr, entities e, folders f, folder_items fi, categories cat, folder_item_snapshots fis
where fi.fold_id=f.id
and f.enti_id=e.id
and e.engr_id=egr.id
and f.cate_id=cat.id
-- and fi.status = 'PUBLISHED'
and fi.id=f.foit_rece_id
-- and e.deletion_date is null
and fis.foit_id=fi.id
and fi.active_snap_id=fis.id
)
group by creation_date, bic11, name, entity_group_name, institution_name, covered) s,
(select name entity_group_name from entity_groups) g
where s.entity_group_name(+)=g.entity_group_name) t2
on t1.bic11=t2.ENTITY_BIC11;
LOOP
FETCH LC_SELECT INTO LR_DETAILS;
EXIT WHEN LC_SELECT%NOTFOUND;
TABLE_OUTPUT.extend();
TABLE_OUTPUT(TABLE_OUTPUT.count()) := LR_DETAILS;
END LOOP;
CLOSE LC_SELECT;
TABLE_OUTPUT := TABLE_OUTPUT;
END;
【问题讨论】:
您不能引用在过程中定义的过程参数的类型。类型必须在过程外部声明。 @jeff6times7 我应该改变哪一部分? 试试this。您只能通过一次,而且仅因为您的头像很酷。 【参考方案1】:您需要在过程之外将TYPE
声明为架构对象。
CREATE OR REPLACE TYPE REC_OUTPUT AS OBJECT(
eorder_date DATE,
entity_bic11 VARCHAR2(20),
ACCOUNT VARCHAR2(100),
COVERED_BY VARCHAR2(20),
ENTITIES_PRIORITIES VARCHAR2(1),
TASK_PRIORITY VARCHAR2(5),
folder_published NUMBER,
NEW_STATUS VARCHAR2(10)
);
CREATE OR REPLACE TYPE TABLE_OUTPUT IS TABLE OF REC_OUTPUT;
所以,在你的过程中,从DECLARE
之后的这一行开始
LC_SELECT SYS_REFCURSOR;
...
...
在您的循环中,您错误地使用了 TYPE
名称 TABLE_OUTPUT
而不是 TYPE
变量 TBL_OUTPUT
这是您的 OUT
参数。正确使用。
【讨论】:
以上是关于必须声明 SQL 标识符,即使已经声明的主要内容,如果未能解决你的问题,请参考以下文章
PL SQL,错误(32,43):PLS-00201:必须声明标识符“HR”
在 PL/SQL 中出现错误“PLS-00201:必须声明标识符‘JSON_VALUE’”
PL/SQL 函数中的 XmlRoot、XmlElement、InsertChildXml 给出 PLS-00201 必须声明标识符