newbie pl/pgsql question

Started by Marco Colomboover 22 years ago1 messagesgeneral
Jump to latest
#1Marco Colombo
marco@esi.it

Is there a way to INSERT / UPDATE a row using the data stored in
a single %ROWTYPE variable?

Something along the line:

DECLARE
onerow table1%ROWTYPE;
BEGIN
-- get the data
SELECT INTO onerow <some expression>;

-- insert them into the table
INSERT INTO table1 VALUES onerow; -- this is not valid of course
END;

I know that:

INSERT INTO table1 VALUES (
onerow.col1,
onerow.col2,
...
onerow.col100);

will work, but i wonder if there's a smarter way.

Same for UPDATE (that one I understand is trickier).

TIA,
.TM.
--
____/ ____/ /
/ / / Marco Colombo
___/ ___ / / Technical Manager
/ / / ESI s.r.l.
_____/ _____/ _/ Colombo@ESI.it