-1

ストアド プロシージャを作成しました

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;

それは私に2つのエラーを与えています

1: エラー(26,5): PLS-00103: 次のいずれかを予期しているときに、記号「INSERT」が検出されました: begin function package pragma procedure subtype type use form current cursor 記号「begin」が「INSERT」の代わりに使用されました.

2: エラー(78,19): PLS-00103: 次のいずれかを予期しているときに、記号「ファイルの終わり」が検出されました: begin case 宣言 end 例外 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;
4

3 に答える 3

0

を取り除いたほうがいいと思いますDECLARE

Oracle 11g 作成手順のドキュメント

于 2013-10-09T17:26:53.487 に答える