oracle apex自定义登录验证

siotufzp  于 2021-07-24  发布在  Java
关注(0)|答案(1)|浏览(417)

我一直在学习本教程:https://www.youtube.com/watch?v=ngom5ubp1ue&feature=emb_title.
我用我需要的变量遵循所有代码,它们如下所示:
-正在创建表

CREATE TABLE  "TB_USERS"
(
    "S_ID" NUMBER GENERATED ALWAYS AS IDENTITY(START with 1 INCREMENT by 1), 
    "S_FNAME" varchar2(30) NOT NULL ENABLE, 
    "S_LNAME" varchar2(30) NOT NULL ENABLE,
    "S_Password" varchar2(30) NOT NULL ENABLE,
    "S_DOB" date NOT NULL ENABLE,
    "EMAIL" varchar2(255) NOT NULL ENABLE,
    PRIMARY KEY ("S_ID") USING INDEX  ENABLE,
    CONSTRAINT "USERS_U1" UNIQUE ("EMAIL") USING INDEX  ENABLE
);

-创建加密函数

CREATE OR REPLACE FUNCTION ENCRYPT_PASSWORD
(
    p_username in varchar2,
    p_password  in varchar2)
return varchar2
is
    l_password varchar2(255);
    l_salt  varchar2(30) := 'RANDOM_SALT_STRING';
begin
    l_password := 
    DBMS_OBFUSCATION_TOOLKIT.MD5(input_string => UPPER(p_username) || l_salt || UPPER(p_password));
    return l_password;
end ENCRYPT_PASSWORD;

这两个sql脚本都是成功的,但是在声明触发器时,会出现错误“ora-04070:invalid trigger name ora-06512:at”sys.wwv\u dbms\u sql\u apex\u 200100“。我为这个脚本编写的代码是:

CREATE OR REPLACE TRIGGER 'TB_USERS_TRIGGER'
    BEFORE INSERT ON TB_USERS
    for each row
BEGIN 
    :new.EMAIL := upper(:new.EMAIL);
    :new.s_fname := lower(:new.s_fname);
    :new.s_password := ENCRYPT_PASSWORD(upper(:new.email), :new.s_password);
END;
/

Insert into TB_USERS ("EMAIL","S_Password") values ('VASCODIGAMA@GMAIL.COM','rainuma_16');
/

你知道我哪里出错了吗?

w3nuxt5m

w3nuxt5m1#

我认为你应该把双引号一起去掉。

SQL> CREATE TABLE TB_USERS
(
    S_ID NUMBER GENERATED ALWAYS AS IDENTITY(START with 1 INCREMENT by 1),
    S_FNAME varchar2(30) NOT NULL ENABLE,
    S_LNAME varchar2(30) NOT NULL ENABLE,
    S_Password varchar2(30) NOT NULL ENABLE,
    S_DOB date NOT NULL ENABLE,
    EMAIL varchar2(255) NOT NULL ENABLE,
    PRIMARY KEY (S_ID) USING INDEX  ENABLE,
    CONSTRAINT USERS_U1 UNIQUE (EMAIL) USING INDEX  ENABLE
); 

Table created.

SQL> CREATE OR REPLACE FUNCTION ENCRYPT_PASSWORD
    (
    p_username in varchar2,
    p_password  in varchar2)
return varchar2
    is
    l_password varchar2(255);
    l_salt  varchar2(30) := 'RANDOM_SALT_STRING';
begin
    l_password :=
    DBMS_OBFUSCATION_TOOLKIT.MD5(input_string => UPPER(p_username) || l_salt || UPPER(p_password));
    return l_password;
end ENCRYPT_PASSWORD;
   /

Function created.

SQL> CREATE OR REPLACE TRIGGER TB_USERS_TRIGGER
    BEFORE INSERT ON TB_USERS
      for each row
BEGIN
    :new.EMAIL := upper(:new.EMAIL);
    :new.s_fname := lower(:new.s_fname);
    :new.s_password := ENCRYPT_PASSWORD(upper(:new.email), :new.s_password);
   END;
/  

Trigger created.

相关问题