Re: plpgsql - Insert from a record variable? - Mailing list pgsql-sql

From Phil Endecott
Subject Re: plpgsql - Insert from a record variable?
Date
Msg-id 6249353@chezphil.org
Whole thread Raw
In response to Re: plpgsql - Insert from a record variable?  (basic <basic@mozdev.org>)
List pgsql-sql
Phil> execute ''column_values :=
Phil>  column_values || quote_literal(r.'' || cr.column_name || '')'';

basic> FOR rec IN EXECUTE
basic>   ''select column_values || quote_literal(r.'' ||
basic>   cr.column_name || '') alias column_values''; LOOP
basic>      column_values := rec.column_values;
basic> END LOOP;

I think your code will try to execute a query like this:

select column_values || quote_literal(r.something) alias column_values

This will fail because column_values and r are both plpgsql variables, and so are not visible to the SQL interpreter.

Any other suggestions?

--Phil.


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: subselect prob in view
Next
From: "Matthew Nuzum"
Date:
Subject: matching rows differing only by fkey,pkey