小弟从来没写过存储过程,自己没研究明白求高人指点!
下面是我现在要做的其中一个表:
CREATE OR REPLACE PACKAGE BODY IN_PRE_REALNAME_REALSITE_PKG is
PROCEDURE PRE_REALNAME_REALSITE IS
V_SU_ID SECURITY_USER.SU_ID%TYPE := SEQ_SECURITY_USER.NEXTVAL;
V_SU_ACTIVE SECURITY_USER.Su_Active%TYPE :=1;
V_SU_ADMIN_FLAG SECURITY_USER.SU_ADMIN_FLAG%TYPE:=0 ;
V_SU_IS_EMPLOYEE SECURITY_USER.SU_IS_EMPLOYEE%type:=0;
V_SU_ENABLED SECURITY_USER.SU_ENABLED%type:=1;
V_BUID SECURITY_USER.BUID%TYPE := SEQ_BU.NEXTVAL;
V_PHONE_NUM SECURITY_USER.PHONE_NUM%type;
V_BU_VERIFIED_STATUS SECURITY_USER.BU_VERIFIED_STATUS%type:=0;
CURSOR C_PRE_REALNAME_REALSITE IS --声明显式游标
select SECURITY_USER__PHONE_NUM into V_PHONE_NUM FROM PRE_REALNAME_REALSITE;
C_ROW_PRE_REALNAME_REALSITE C_PRE_REALNAME_REALSITE%ROWTYPE; --定义游标变量,该变量的类型为基于游标的记录
BEGIN
FOR C_ROW_PRE_REALNAME_REALSITE IN C_PRE_REALNAME_REALSITE LOOP
insert into SECURITY_USER(SU_ID,SU_ACTIVE,SU_ADMIN_FLAG,SU_IS_EMPLOYEE,SU_ENABLED,BUID,PHONE_NUM,BU_VERIFIED_STATUS) values(V_SU_ID,V_SU_ACTIVE,V_SU_ADMIN_FLAG,V_SU_IS_EMPLOYEE,V_SU_ENABLED,V_BUID,V_PHONE_NUM,V_BU_VERIFIED_STATUS);
COMMIT;
END LOOP;
END;
END IN_PRE_REALNAME_REALSITE_PKG;
以上报错违反唯一约束,游标我还不太会用 ,现在能编译,但是数据插入不进去!求帮忙更改! 谢谢好心人!
下面是我现在要做的其中一个表:
CREATE OR REPLACE PACKAGE BODY IN_PRE_REALNAME_REALSITE_PKG is
PROCEDURE PRE_REALNAME_REALSITE IS
V_SU_ID SECURITY_USER.SU_ID%TYPE := SEQ_SECURITY_USER.NEXTVAL;
V_SU_ACTIVE SECURITY_USER.Su_Active%TYPE :=1;
V_SU_ADMIN_FLAG SECURITY_USER.SU_ADMIN_FLAG%TYPE:=0 ;
V_SU_IS_EMPLOYEE SECURITY_USER.SU_IS_EMPLOYEE%type:=0;
V_SU_ENABLED SECURITY_USER.SU_ENABLED%type:=1;
V_BUID SECURITY_USER.BUID%TYPE := SEQ_BU.NEXTVAL;
V_PHONE_NUM SECURITY_USER.PHONE_NUM%type;
V_BU_VERIFIED_STATUS SECURITY_USER.BU_VERIFIED_STATUS%type:=0;
CURSOR C_PRE_REALNAME_REALSITE IS --声明显式游标
select SECURITY_USER__PHONE_NUM into V_PHONE_NUM FROM PRE_REALNAME_REALSITE;
C_ROW_PRE_REALNAME_REALSITE C_PRE_REALNAME_REALSITE%ROWTYPE; --定义游标变量,该变量的类型为基于游标的记录
BEGIN
FOR C_ROW_PRE_REALNAME_REALSITE IN C_PRE_REALNAME_REALSITE LOOP
insert into SECURITY_USER(SU_ID,SU_ACTIVE,SU_ADMIN_FLAG,SU_IS_EMPLOYEE,SU_ENABLED,BUID,PHONE_NUM,BU_VERIFIED_STATUS) values(V_SU_ID,V_SU_ACTIVE,V_SU_ADMIN_FLAG,V_SU_IS_EMPLOYEE,V_SU_ENABLED,V_BUID,V_PHONE_NUM,V_BU_VERIFIED_STATUS);
COMMIT;
END LOOP;
END;
END IN_PRE_REALNAME_REALSITE_PKG;
以上报错违反唯一约束,游标我还不太会用 ,现在能编译,但是数据插入不进去!求帮忙更改! 谢谢好心人!
涛筱涛

