pgplsql, how to save row variable to a table row

From: "josep porres" <jmporres(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: pgplsql, how to save row variable to a table row
Date: 2008-03-26 11:59:54
Message-ID: d2d532610803260459w1473f792se96bbbb8eb67135f@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

i'm learning how to work with rows (rowtype) , but I cannot find a way to
insert one, once i filled up the fields, in a table.
the thing is: I have some rows filled up with execute commands as you can
see below.
Once I've filled the row_tempf, how can I insert this row to the table
f2_tempfac? Can I use the execute command for that?

Thanks!

Josep Porres

DECLARE
row_tfa f2_tarifa_a%rowtype;
row_tempf f2_tempfac%rowtype;
...
BEGIN

...

BEGIN
EXECUTE 'SELECT * FROM F2_TARIFA_A
WHERE (TIPUS = ' || quote_literal(f2_Mtar) || ')
AND ' || quote_literal(datafac) || ' BETWEEN DINICI AND
DFINAL'
INTO STRICT row_tfa;
EXCEPTION
WHEN NO_DATA_FOUND THEN
RAISE EXCEPTION 'TARIFA_A % no trobada.', f2_Mtar;
WHEN TOO_MANY_ROWS THEN
RAISE EXCEPTION 'TARIFA_A % no unica.', f2_Mtar;
END;

...

row_tempf.field1 := value1;
row_tempf.field2 := value3;
...
row_tempf.fieldN := valueN;

-- NOW INSERT row_tempf in the associated table
-- ???

END;

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Zdeněk Kotala 2008-03-26 12:02:15 Re: pg_ctrl stop problems (psql 8.2.5)
Previous Message srdjan 2008-03-26 11:54:32 Re: RULES and QUALIFICATION for INSERT