I have a plpgsql function:
CREATE OR REPLACE FUNCTION test() RETURNS VOID AS
$$
DECLARE
my_row my_table%ROWTYPE;
BEGIN
SELECT * INTO my_row FROM my_table WHERE id='1';
my_row.date := now();
END;
$$ LANGUAGE plpgsql;
I would like to know if a record can be updated directly my_row.
The only way I found this now is:
UPDATE my_table SET date=now() WHERE id='1';
Please note that this is only an example function, the real one is much more complicated than this.
I am using PostgreSQL 9.2.
UPDATE:
Sorry for the confusion, I wanted to say:
SELECT * INTO my_row FROM my_table INTO my_row WHERE id='1';
make_lots_of_complicated_modifications_to(my_row, other_complex_parameters);
UPDATE my_row;
those. Use my_ rowto store information in the base table. I have many options for updating.
source
share