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', '[email protected]', '88888888', 1, 1);

Note: My user is added to the database

3
  • You should really avoid those dreaded quoted identifiers. They are much more trouble than they are worth it. wiki.postgresql.org/wiki/… Commented May 15, 2020 at 15:42
  • "cNewUsername" not cNewUsername Commented May 15, 2020 at 15:43
  • Thanks for the reply. Still same error with "" Commented May 15, 2020 at 15:50

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.