Changes between Version 19 and Version 20 of DatabaseProgramming


Ignore:
Timestamp:
06/11/26 11:14:12 (5 days ago)
Author:
231028
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DatabaseProgramming

    v19 v20  
    707707    execute function enforce_offer_validity();
    708708}}}
     709
     710{{{
     711create or replace function unique_email_and_phone()
     712returns trigger
     713as
     714    $$
     715    begin
     716        if exists(
     717            select 1
     718            from appuser
     719            where appuser.email=NEW.email
     720        ) then
     721            raise exception 'User with this email already exists';
     722        end if ;
     723        if exists(
     724            select 1
     725            from appuser
     726            where appuser.phone_number=NEW.phone_number
     727        ) then
     728            raise exception 'User with this phone number already exists';
     729        end if ;
     730    end;
     731    $$;
     732create trigger check_valid_email_and_phone_number
     733before insert on Appuser
     734for each row
     735execute function unique_email_and_phone()
     736}}}