0

Hi im trying to create a trigger after insert on the tUser table.

I made my trigger function and it connected.

Now i get an error saying: column "cnewusername" of relation "tAuditUser" does not exist. Now this is the first value of my tAuditUser table, so i guess the problem will continue throughout the values.

This is my code:

create or replace function auditUserInsert() returns trigger as $userAuditInsert$
begin
insert into public."tAuditUser"
( 
    cNewUsername, 
    cNewPassword, 
    cNewEmail, 
    cNewPhoneNumber, 
    nPhoneCodeID, 
    nCountryCodeID, 
    dJoinDate)
values
(
    new.cUsername,
    new.cPassword, 
    new.cEmail, 
    new.cPhoneNumber, 
    new.nPhoneCodeID,   
    new.nCountryCodeID,  
    current_timestamp
);
return new;
end;
$userAuditInsert$ language plpgsql;


create trigger trgAuditUserInsert after insert on public."tUser"
for each row execute procedure auditUserInsert();

The user i add has the values:

INSERT INTO public."tUser"("cUsername", "cPassword", "cEmail", "cPhoneNumber", "nPhoneCodeID", "nCountryCodeID")
    VALUES ('Testname', '123', 'e@e.dk', '88888888', 1, 1);

Note: My user is added to the database

a_horse_with_no_name
  • 497,550
  • 91
  • 775
  • 843

0 Answers0