Search Postgresql Archives

pgplsql, how to save row variable to a table row

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux