Re: plpgsql - Insert from a record variable?

From: "Phil Endecott" <spam_from_postgresql_sql(at)chezphil(dot)org>
To: basic <basic(at)mozdev(dot)org>, pgsql-sql(at)postgresql(dot)org
Subject: Re: plpgsql - Insert from a record variable?
Date: 2004-06-22 14:05:20
Message-ID: 6249353@chezphil.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Alvaro Sanchez-Mariscal 2004-06-22 14:56:10 Unrecognized node type
Previous Message Tom Lane 2004-06-22 13:56:27 Re: subselect prob in view