我正在尝试在包
中使用%rowtype
create or replace PACKAGE p IS
procedure TYPE_INSERT_DUMMY(ins acr_projected_new%ROWTYPE);
END p;
create or replace PACKAGE BODY p IS
PROCEDURE TYPE_INSERT_DUMMY (ins acr_projected_new%ROWTYPE)
IS
BEGIN
insert into ins(WEEKEND_DATE,USERID,TIMESTAMP,ACR_PROJECTED,ARTIFICIAL_ID)
values(sysdate,'NN57875',sysdate,1,1);
end TYPE_INSERT_DUMMY;
end p;
当我尝试上面的代码时,我收到错误:
错误(6,1):PL / SQL:忽略SQL语句
错误(6,13):PL / SQL:ORA-00942:表或视图不存在
答案 0 :(得分:1)
如果要将数据插入表类型变量,则不能使用insert into
语法。
在Package spec中,您可以定义 TYPE
在Package Body的过程中,您创建一个 TYPE 的新对象,然后使用extend
插入值
CREATE OR REPLACE PACKAGE p
IS
Type ins is table of acr_projected_new%ROWTYPE
PROCEDURE TYPE_INSERT_DUMMY;
END p;
CREATE OR REPLACE PACKAGE BODY p
IS
PROCEDURE TYPE_INSERT_DUMMY()
IS
insvariable ins := ins();
BEGIN
insvariable.extend(1);
insvariable(insvariable.LAST) := ins(sysdate,'NN57875',sysdate,1,1);
END TYPE_INSERT_DUMMY;
END p;
答案 1 :(得分:0)
我在下面试过,它对我有用:
create or replace PACKAGE p
IS
procedure TYPE_INSERT_DUMMY;
END p;
create or replace PACKAGE BODY p IS
PROCEDURE TYPE_INSERT_DUMMY
IS
Type acr is table of acr_projected_new%ROWTYPE;
ins acr;
BEGIN
select sysdate, 'NN57875', sysdate, 1, 1
bulk collect into ins
from dual;
END TYPE_INSERT_DUMMY;
end p;