Re: quick q re execute & scope of new - Mailing list pgsql-general

From Scott Ribe
Subject Re: quick q re execute & scope of new
Date
Msg-id 37770D76-41DE-451F-BD2A-AE9E0081B1AB@elevated-dev.com
Whole thread Raw
In response to Re: quick q re execute & scope of new  (Adrian Klaver <adrian.klaver@aklaver.com>)
Responses Re: quick q re execute & scope of new
Re: quick q re execute & scope of new
List pgsql-general
On Apr 2, 2015, at 10:14 PM, Adrian Klaver <adrian.klaver@aklaver.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
astring 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@elevated-dev.com
http://www.elevated-dev.com/
https://www.linkedin.com/in/scottribe/
(303) 722-0567 voice







pgsql-general by date:

Previous
From: Scott Ribe
Date:
Subject: Re: quick q re execute & scope of new
Next
From: Tom Lane
Date:
Subject: Re: Error handling in C API function calls in a way that doesn't close client connection