lundi 20 juillet 2020

Create procedure with if in oracle sql

I need to create a procedure that search an email in a table, and if it doesn´t exists the procedure creates a new table with this email.

Something like this:

CREATE PROCEDURE check_email (in @email varchar2(99)) AS

BEGIN
 IF SELECT email FROM user u WHERE u.email:=email
 
     dbms_output.put_line('This email exists');
    
 ELSE 
 
    BEGIN
        INSERT INTO user (id, name, surname, city, address, age, email) VALUES (id_user.nextval,'David','Alcatraz','Sevilla', 'Avd miguel de unamuno', 23, email || '@gmail.com')
    END

Aucun commentaire:

Enregistrer un commentaire