我创建了两个表 第一个是
create SEQUENCE seg_cod start 1 increment 1 ;
create table value
(
id int primary key default nextval ( ' seg_cod ' ) ,
first varchar ( 10 ) not null
);
,第二个是
create SEQUENCE seg_codRsult start 1 increment 1 ;
create table result
(
id int primary key default nextval ( ' seg_codRsult ' ) ,
primeiroR varchar ( 10 ) not null
);
我想创建一个触发器,当在表1中插入表时,表1中的insirar作为结果,如果false insirar表结果值为0,表中的值将测试我;
result value
true 1
false 0
true 1
true 1
false 0
我知道要创建一个触发器必须先创建一个函数然后触发器才会调用这个函数,因为这就是我喜欢坐下来的东西;
create ResulV function ( ) RETURNS TRIGGER AS $ $
begin
if new.primeiro = 'true ' then
insert into result values ( primeiroR + 1 ) ;
else
insert into result values ( primeiroR + 0 ) ;
end if ;
return null;
end ;
$ $ LANGUAGE plpgsql ;
triggerResulV create trigger on after insert value for each row execute
ResulV procedure ();
当我将数据插入表值时,它给出了此错误消息
ERROR : " primeiror " column does not exist
LINE 1 : insert into results values ( primeiroR + 1 )
^
HINT : There is a " primeiror " column called , in the table "result " , but it can not be referenced from this part of the query .
QUERY : insert into results values ( primeiroR + 1 )
CONTEXT : PL / pgSQL resulv ( ) function in SQL command line 6
Error ********** **********
ERROR : " primeiror " column does not exist
SQL state: 42703
Hint : There is a " primeiror " column called , in the table "result " , but it can not be referenced from this part of the query .
Context : PL / pgSQL resulv ( ) function in SQL command line 6
需要帮助