pgplsql, how to save row variable to a table row
От | josep porres |
---|---|
Тема | pgplsql, how to save row variable to a table row |
Дата | |
Msg-id | d2d532610803260459w1473f792se96bbbb8eb67135f@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: pgplsql, how to save row variable to a table row
|
Список | 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;
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 по дате отправления: