Re: Where - Mailing list pgsql-general

From Uwe C. Schroeder
Subject Re: Where
Date
Msg-id 200511101534.34923.uwe@oss4u.com
Whole thread Raw
In response to Where  (Bob Pawley <rjpawley@shaw.ca>)
List pgsql-general
SELECT INTO xxxx
tries to create table xxxx
See: http://www.postgresql.org/docs/8.0/interactive/sql-selectinto.html

Why do you do the select into anyways? It does nothing.
If you try to update table pipe with the select result you have the wrong
command.

UC

On Thursday 10 November 2005 14:24, Bob Pawley wrote:
> I am attempting to transfer the data in the fluid_id column of table
> process into column fluid_id of table pipe.
>
> This should happen only when column contain of table process holds the
> value 'ip'.
>
> Here is the command that I am having trouble with.
> -------
> create table process (fluid_id integer primary key, process varchar,
> contain varchar);
>
> create table pipe ( fluid_id integer not null, contain varchar);
>
>
>
> create or replace function base() returns trigger as $$
>
>             begin
>
>
>
>             insert into pipe (fluid_id) values (new.fluid_id);
>
>             select * into pipe from process where contain = 'ip';
>
>
>
>             return null;
>
>
>
>             end;
>
>             $$ language plpgsql;
>
>
>
>             create trigger trig1 after insert on process
>
>
>
>             for each row execute procedure base();
>
>
>
>     insert into process (fluid_id, process, contain)
>
>             values ('2', 'water', 'ip');
>
> -------------------
> On inserting data this error comes back -
> -------
> ERROR:  relation "pipe" already exists
> CONTEXT:  SQL statement "SELECT  * INTO  pipe from process where contain =
> 'ip'" PL/pgSQL function "base" line 4 at SQL statement
> ------
> Of course the table pipe does already exist - it is a permanent table.
>
> Is the program looking for some other target??  Perhaps a temporary table??
>
>
>
> Or am I completely screwed up???
>
>
>
> Bob

--
    UC

--
Open Source Solutions 4U, LLC    2570 Fleetwood Drive
Phone:  +1 650 872 2425        San Bruno, CA 94066
Cell:   +1 650 302 2405        United States
Fax:    +1 650 872 2417

pgsql-general by date:

Previous
From: Richard Sydney-Smith
Date:
Subject: Re: pgdump from 8.0.4 not valid for import into 8.1.0
Next
From: Michael Fuhr
Date:
Subject: Re: TIMESTAMP vs TIMESTAMP WITHOUT TIME ZONE