Обсуждение: newbie pl/pgsql question

Поиск
Список
Период
Сортировка

newbie pl/pgsql question

От
Marco Colombo
Дата:
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