我创建了一个存储过程
create or replace
PROCEDURE "USP_USER_ADD" (
USERNAME IN VARCHAR2 ,
P_PASSWORD IN VARCHAR2 ,
SALT IN BLOB ,
EMAIL IN VARCHAR2 ,
FIRST_NAME IN VARCHAR2 ,
LAST_NAME IN VARCHAR2 ,
ip_address IN VARCHAR2 ,
EMAIL_VERIFIED IN NUMBER ,
ACTIVE IN NUMBER ,
CREATEDBY IN VARCHAR2 ,
CREATED IN DATE ,
MODIFIED IN DATE ,
MODIFIEDBY IN VARCHAR2 ,
USER_GROUP_ID IN NUMBER ,
LAST_PASSWORD_CHANGE_DATE IN DATE ,
P_failed_login_attempts IN NUMBER )
AS
BEGIN
declare
user_id_tmp number(20);
INSERT INTO users( "username" ,
"password" ,
"salt" ,
"email" ,
"first_name" ,
"last_name" ,
"email_verified" ,
"active" ,
"ip_address" ,
"created" ,
"createdby" ,
"modified" ,
"modifiedby" ,
"user_group_id" ,
"last_password_change_date" ,
"FAILED_LOGIN_ATTEMPTS"
)
VALUES
(
username ,
p_password ,
salt ,
email ,
first_name ,
last_name ,
email_verified ,
active ,
ip_address ,
created ,
createdby ,
modified ,
modifiedby ,
user_group_id ,
last_password_change_date ,
p_failed_login_attempts
);
SELECT MAX(id) INTO user_id_tmp FROM users ;
INSERT INTO user_passwords
(
"user_id" ,
"password" ,
"created"
)
VALUES
(
user_id_tmp,
p_password,
created
);
END USP_USER_ADD;
它给了我两个错误
1:错误(26,5):PLS-00103:在预期以下情况之一时遇到符号“INSERT”:开始函数包杂注过程子类型类型使用当前光标符号“开始”替换“插入”以继续.
2:错误(78,19):PLS-00103:在预期以下情况之一时遇到符号“文件结尾”:begin case declare end exception exit for goto if loop mod null pragma raise return select update while with < <关闭当前删除获取锁插入打开回滚保存点设置sql执行提交forall合并管道
这些是我的桌子
--------------------------------------------------------
-- DDL for Table USER_PASSWORDS
--------------------------------------------------------
CREATE TABLE "NEWS1.0"."USER_PASSWORDS"
( "ID" NUMBER(11,0),
"USER_ID" NUMBER(11,0),
"PASSWORD" VARCHAR2(255 BYTE),
"SALT" VARCHAR2(255 BYTE),
"IP" VARCHAR2(15 BYTE),
"CREATEDBY" VARCHAR2(255 BYTE),
"CREATED" DATE,
"MODIFIED" DATE,
"MODIFIEDBY" VARCHAR2(255 BYTE)
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "USERS" ;
--------------------------------------------------------
-- DDL for Index USERS_PK
--------------------------------------------------------
CREATE UNIQUE INDEX "NEWS1.0"."USERS_PK" ON "NEWS1.0"."USER_PASSWORDS"
("ID")
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "USERS" ;
--------------------------------------------------------
-- Constraints for Table USER_PASSWORDS
--------------------------------------------------------
ALTER TABLE "NEWS1.0"."USER_PASSWORDS" MODIFY ("ID" NOT NULL ENABLE);
ALTER TABLE "NEWS1.0"."USER_PASSWORDS" MODIFY ("USER_ID" NOT NULL ENABLE);
ALTER TABLE "NEWS1.0"."USER_PASSWORDS" MODIFY ("PASSWORD" NOT NULL ENABLE);
ALTER TABLE "NEWS1.0"."USER_PASSWORDS" ADD CONSTRAINT "USERS_PK" PRIMARY
KEY ("ID")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "USERS" ENABLE;
--------------------------------------------------------
-- DDL for Trigger BI_USER_PASSWORDS_ID
--------------------------------------------------------
CREATE OR REPLACE TRIGGER "NEWS1.0"."BI_USER_PASSWORDS_ID"
before insert on "USER_PASSWORDS"
for each row
begin
if inserting then
if :NEW."ID" is null then
select USER_PASSWORDS_SEQ.nextval into :NEW."ID" from dual;
end if;
end if;
end;
/
ALTER TRIGGER "NEWS1.0"."BI_USER_PASSWORDS_ID" ENABLE;
--------------------------------------------------------
-- DDL for Table USERS
--------------------------------------------------------
CREATE TABLE "NEWS1.0"."USERS"
( "ID" NUMBER(*,0),
"USERNAME" VARCHAR2(100 BYTE),
"PASSWORD" VARCHAR2(255 BYTE),
"SALT" BLOB,
"EMAIL" VARCHAR2(100 BYTE),
"FIRST_NAME" VARCHAR2(100 BYTE),
"LAST_NAME" VARCHAR2(100 BYTE),
"EMAIL_VERIFIED" NUMBER(*,0) DEFAULT 1,
"ACTIVE" NUMBER(*,0) DEFAULT 1,
"IP_ADDRESS" VARCHAR2(50 BYTE),
"USER_GROUP_ID" NUMBER(*,0),
"LAST_PASSWORD_CHANGE_DATE" DATE,
"FAILED_LOGIN_ATTEMPTS" NUMBER(*,0),
"CREATED" DATE,
"CREATEDBY" VARCHAR2(255 BYTE),
"MODIFIED" DATE,
"MODIFIEDBY" VARCHAR2(255 BYTE)
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "USERS"
LOB ("SALT") STORE AS (
TABLESPACE "USERS" ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10
NOCACHE LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)) ;
--------------------------------------------------------
-- DDL for Index USERS_UK2
--------------------------------------------------------
CREATE UNIQUE INDEX "NEWS1.0"."USERS_UK2" ON "NEWS1.0"."USERS" ("EMAIL")
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "USERS" ;
--------------------------------------------------------
-- DDL for Index USERS_UK1
--------------------------------------------------------
CREATE UNIQUE INDEX "NEWS1.0"."USERS_UK1" ON "NEWS1.0"."USERS" ("USERNAME")
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "USERS" ;
--------------------------------------------------------
-- Constraints for Table USERS
--------------------------------------------------------
ALTER TABLE "NEWS1.0"."USERS" MODIFY ("ID" NOT NULL ENABLE);
ALTER TABLE "NEWS1.0"."USERS" MODIFY ("USERNAME" NOT NULL ENABLE);
ALTER TABLE "NEWS1.0"."USERS" MODIFY ("PASSWORD" NOT NULL ENABLE);
ALTER TABLE "NEWS1.0"."USERS" ADD CONSTRAINT "USERS_UK1" UNIQUE
("USERNAME")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "USERS" ENABLE;
ALTER TABLE "NEWS1.0"."USERS" ADD CONSTRAINT "USERS_UK2" UNIQUE ("EMAIL")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "USERS" ENABLE;