pgplsql, how to save row variable to a table row - Mailing list pgsql-general

From josep porres
Subject pgplsql, how to save row variable to a table row
Date
Msg-id d2d532610803260459w1473f792se96bbbb8eb67135f@mail.gmail.com
Whole thread Raw
Responses Re: pgplsql, how to save row variable to a table row  (Raymond O'Donnell <rod@iol.ie>)
List 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;

pgsql-general by date:

Previous
From: "Albe Laurenz"
Date:
Subject: Re: RULES and QUALIFICATION for INSERT
Next
From: Zdeněk Kotala
Date:
Subject: Re: pg_ctrl stop problems (psql 8.2.5)