首页 > 解决方案 > Postgres:关系不存在错误,Postgres

问题描述

您好我试图在 tUser 表上插入后创建触发器。

我做了我的触发功能,它连接了。

现在我收到一条错误消息:关系“tAuditUser”的列“cnewusername”不存在。现在这是我的 tAuditUser 表的第一个值,所以我猜这个问题将在整个值中继续存在。

这是我的代码:

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();

我添加的用户具有以下值:

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

注意:我的用户已添加到数据库中

标签: postgresqlquoted-identifier

解决方案


推荐阅读