[英]PLS-00201 - identifier must be declared
I executed a PL/SQL script that created the following table 我执行了一个创建下表的PL / SQL脚本
TABLE_NAME VARCHAR2(30) := 'B2BOWNER.SSC_Page_Map';
I made an insert function for this table using arguments 我使用参数为这个表创建了一个insert函数
CREATE OR REPLACE FUNCTION F_SSC_Page_Map_Insert(
p_page_id IN B2BOWNER.SSC_Page_Map.Page_ID_NBR%TYPE,
p_page_type IN B2BOWNER.SSC_Page_Map.Page_Type%TYPE,
p_page_dcpn IN B2BOWNER.SSC_Page_Map.Page_Dcpn%TYPE)
I was notified I had to declare B2BOWNER.SSC_Page_Map
prior to it appearing as an argument to my function. 我收到通知我必须在它作为我的函数的参数出现之前声明
B2BOWNER.SSC_Page_Map
。 Why am I getting this error? 为什么我收到此错误?
EDIT : Actual error 编辑 :实际错误
Warning: compiled but with compilation errors
Errors for FUNCTION F_SSC_PAGE_MAP_INSERT
LINE/COL ERROR
-------- -----------------------------------------------------------------
2/48 PLS-00201: identifier 'SSC_PAGE_MAP.PAGE_ID_NBR' must be declared
0/0 PL/SQL: Compilation unit analysis terminated
EDIT: Complete PL/SQL Function 编辑:完整的PL / SQL函数
RETURN INTEGER
IS
TABLE_DOES_NOT_EXIST exception;
PRAGMA EXCEPTION_INIT(TABLE_DOES_NOT_EXIST, -942); -- ORA-00942
BEGIN
INSERT INTO
B2BOWNER.SSC_Page_Map VALUES(
p_page_id,
p_page_type,
p_page_dcpn);
RETURN 0;
EXCEPTION
WHEN TABLE_DOES_NOT_EXIST THEN
RETURN -1;
WHEN DUP_VAL_ON_INDEX THEN
RETURN -2;
WHEN INVALID_NUMBER THEN
RETURN -3;
WHEN OTHERS THEN
RETURN -4;
END;
SHOW ERRORS PROCEDURE F_SSC_Page_Map_Insert;
GRANT EXECUTE ON F_SSC_Page_Map_Insert TO B2B_USER_DBROLE;
RETURN INTEGER
EDIT: I change the arguments and received a new error related to the insert command 编辑:我更改参数并收到与insert命令相关的新错误
CREATE OR REPLACE FUNCTION F_SSC_Page_Map_Insert(
p_page_id IN INTEGER,
p_page_type IN VARCHAR2,
p_page_dcpn IN VARCHAR2)
RETURN INTEGER
IS
TABLE_DOES_NOT_EXIST exception;
PRAGMA EXCEPTION_INIT(TABLE_DOES_NOT_EXIST, -942); -- ORA-00942
BEGIN
INSERT INTO
B2BOWNER.SSC_Page_Map VALUES(
p_page_id,
p_page_type,
p_page_dcpn);
The error 错误
Errors for FUNCTION F_SSC_PAGE_MAP_INSERT
LINE/COL ERROR
-------- -----------------------------------------------------------------
17/18 PL/SQL: ORA-00942: table or view does not exist
16/5 PL/SQL: SQL Statement ignored
The tables has been verified within the correct schema and with the correct attribute names and types 这些表已在正确的模式中验证,并具有正确的属性名称和类型
EDIT: I executed the following command to check if I have access 编辑:我执行以下命令来检查我是否有权访问
DECLARE
count_this INTEGER;
BEGIN
select count(*) into count_this
from all_tables
where owner = 'B2BOWNER'
and table_name = 'SSC_PAGE_MAP';
DBMS_OUTPUT.PUT_LINE(count_this);
END;
The output I received is 我收到的输出是
1
PL/SQL procedure successfully completed.
I have access to the table. 我可以访问该表。
EDIT: 编辑:
So I finally conducted an insert into the table via the schema using PL/SQL and it worked fine. 所以我最终使用PL / SQL通过模式对表进行了插入,并且工作正常。 It appears I simply do not have authority to create functions but that is an assumption.
看起来我根本没有创建功能的权限,但这是一个假设。
EDIT: 编辑:
Actual table DDL statement 实际表DDL语句
v_create := 'CREATE TABLE ' || TABLE_NAME || ' (
PAGE_ID_NBR NUMERIC(10) NOT NULL Check(Page_ID_NBR > 0),
PAGE_TYPE VARCHAR2(50) NOT NULL,
PAGE_DCPN VARCHAR2(100) NOT NULL,
PRIMARY KEY(Page_ID_NBR, Page_Type))';
EXECUTE IMMEDIATE v_create;
COMMIT WORK;
COMMIT COMMENT 'Create Table';
When creating the TABLE under B2BOWNER
, be sure to prefix the PL/SQL function with the Schema name; 在
B2BOWNER
下创建TABLE时,请确保在PL / SQL函数B2BOWNER
加上Schema名称; ie B2BOWNER.F_SSC_Page_Map_Insert
. 即
B2BOWNER.F_SSC_Page_Map_Insert
。
I did not realize this until the DBAs pointed it out. 在DBA指出之前我没有意识到这一点。 I could have created the table under my root USER/SCHEMA and the PL/SQL function would have worked fine.
我可以在我的根USER / SCHEMA下创建表,PL / SQL函数可以正常工作。
The procedure name should be in caps while creating procedure in database. 在数据库中创建过程时,过程名称应为大写。 You may use small letters for your procedure name while calling from Java class like:
从Java类调用时,您可以使用小写字母作为过程名称,如:
String getDBUSERByUserIdSql = "{call getDBUSERByUserId(?,?,?,?)}";
In database the name of procedure should be: 在数据库中,过程的名称应该是:
GETDBUSERBYUSERID -- (all letters in caps only)
This serves as one of the solutions for this problem. 这是该问题的解决方案之一。
你应该对你的数据库给予许可
grant execute on (packageName or tableName) to user;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.