Is it databases in general, SQL or Postgresql? - Mailing list pgsql-general
From | Bob Pawley |
---|---|
Subject | Is it databases in general, SQL or Postgresql? |
Date | |
Msg-id | 006801c5ea09$f3d0f490$ac1d4318@OWNER Whole thread Raw |
Responses |
Re: Is it databases in general, SQL or Postgresql?
Re: Is it databases in general, SQL or Postgresql? Re: Is it databases in general, SQL or Postgresql? |
List | pgsql-general |
Sample 1
create table pr
(Process_Name varchar (60) not null, Fluid_ID serial, Fluid varchar (30) not null, contain varchar (3),
constraint pr_pk primary key (fluid_id));
create table pi
(process_name varchar (60), Fluid_ID int4 not null, Fluid varchar (30),
contain varchar (3),
constraint pi_pk primary key (fluid_id),
constraint pi_fluid_id foreign key (fluid_id)
references pr (fluid_id) );
create or replace function base() returns trigger as $$
begin
insert into pi (fluid_id) values (new.fluid_id);
return null;
end;
$$ language plpgsql;
create trigger trig1 after insert on pr
for each row execute procedure base();
insert into pr (process_name, fluid, contain)
values ('boiler_water', 'water','ip');
---------------------------------
Sample 2
create table pr
(Process_Name varchar (60) not null, Fluid_ID serial, Fluid varchar (30) not null, contain varchar (3),
constraint pr_pk primary key (fluid_id));
create table pi
(process_name varchar (60), Fluid_ID int4 not null, Fluid varchar (30),
contain varchar (3),
constraint pi_pk primary key (fluid_id),
constraint pi_fluid_id foreign key (fluid_id)
references pr (fluid_id) );
create or replace function base() returns trigger as $$
begin
insert into pi (fluid_id) values (new.fluid_id)
where pr (contain) = 'ip';
return null;
end;
$$ language plpgsql;
create trigger trig1 after insert on pr
for each row execute procedure base();
insert into pr (process_name, fluid, contain)
values ('boiler_water', 'water','ip');
Error Message
ERROR: syntax error at or near "where" at character 41
QUERY: insert into pi (fluid_id) values ( $1 ) where pr (contain) = 'ip'CONTEXT: PL/pgSQL function "base" line 2 at SQL statement
pgsql-general by date: