什么是错的这个包的声明和定义单独
问题描述:
package cpac
as
STGFILE xyz_INSTANCE.FILENAME%TYPE;
procedure POC (cid in xyz_instance.client_id%type,
stgtype in xyz_instance.stg_instance%type,
stgsrc in xyz_instance.stg_source%type);
end;
package body cpac
as
procedure POC (cid in xyz_instance.client_id%type,
stgtype in xyz_instance.stg_instance%type,
stgsrc in xyz_instance.stg_source%type
) Is
BEGIN
select filename
into stgfile
from xyz_instance
where stg_instance = stgtype
and stg_source = stgsrc
and client_id = cid;
END POC;
begin
POC('0123','19517','L');
dbms_output.put_line(STGFILE);
end cpac;
SQL语句被单独执行,程序包含SQL也执行,但只在包我得到的错误是:在4号线什么是错的这个包的声明和定义单独
错误
ORA-00900:http://docstore.mik.ua/orelly/oracle/prog2/ch16_02.htm
:无效的SQL语句,
从以下文件引用了
答
前缀包标题和正文创建与CREATE OR REPLACE
:
CREATE OR REPLACE package cpac
as
STGFILE xyz_INSTANCE.FILENAME%TYPE;
procedure POC (cid in xyz_instance.client_id%type,
stgtype in xyz_instance.stg_instance%type,
stgsrc in xyz_instance.stg_source%type);
end;
/
CREATE OR REPLACE package body cpac
as
procedure POC (cid in xyz_instance.client_id%type,
stgtype in xyz_instance.stg_instance%type,
stgsrc in xyz_instance.stg_source%type
) Is
BEGIN
select filename
into stgfile
from xyz_instance
where stg_instance = stgtype
and stg_source = stgsrc
and client_id = cid;
END POC;
begin
POC('0123','19517','L');
dbms_output.put_line(STGFILE);
end cpac;
/
编辑:如果您没有权限来创建一个包,那么你就不能创建一个包。但是,您仍然可以在匿名PL/SQL块的DECLARE
部分中创建过程或函数,并在该块的后面运行过程/函数。在下面的示例,我的登录身份不具有权限创建存储过程的用户,所以我得到一个错误试图创建一个:
SQL> create or replace procedure test as begin null; end;
2/
create or replace procedure test as begin null; end;
*
ERROR at line 1:
ORA-01031: insufficient privileges
SQL> DECLARE
2 stgfile xyz_instance.filename%TYPE;
3
4 procedure POC (cid in xyz_instance.client_id%type,
5 stgtype in xyz_instance.stg_instance%type,
6 stgsrc in xyz_instance.stg_source%type
7 ) Is
8 BEGIN
9 select filename
10 into stgfile
11 from xyz_instance
12 where stg_instance = stgtype
13 and stg_source = stgsrc
14 and client_id = cid;
15 END POC;
16
17 begin
18 POC('0123','19517','L');
19 dbms_output.put_line(STGFILE);
20 end;
21/
test-filename.txt
PL/SQL procedure successfully completed.
而不是仅仅给予负面状态什么错用质疑自己。 – Prashant 2014-09-22 11:51:50