Re: quick q re execute & scope of new

From: Scott Ribe <scott_ribe(at)elevated-dev(dot)com>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Cc: Postgresql General <pgsql-general(at)postgresql(dot)org>
Subject: Re: quick q re execute & scope of new
Date: 2015-04-03 04:59:38
Message-ID: 37770D76-41DE-451F-BD2A-AE9E0081B1AB@elevated-dev.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Apr 2, 2015, at 10:14 PM, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> wrote:
>
> EXECUTE 'insert into ' || quote_ident(tblname) || ' values(' || new.* || ')'

Not that easy, strings are not quoted correctly, and null values are blank. Might be a function to translate new.* into a string as needed for this use, but I found another way based on Tom's suggestion:

execute('insert into ' || tblnm || ' select $1.*') using new;

--
Scott Ribe
scott_ribe(at)elevated-dev(dot)com
http://www.elevated-dev.com/
https://www.linkedin.com/in/scottribe/
(303) 722-0567 voice

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2015-04-03 05:00:57 Re: Error handling in C API function calls in a way that doesn't close client connection
Previous Message Scott Ribe 2015-04-03 04:57:51 Re: quick q re execute & scope of new