Re: quick q re execute & scope of new

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Scott Ribe <scott_ribe(at)elevated-dev(dot)com>
Cc: Postgresql General <pgsql-general(at)postgresql(dot)org>
Subject: Re: quick q re execute & scope of new
Date: 2015-04-03 14:19:22
Message-ID: 551EA16A.30001@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 04/02/2015 09:59 PM, Scott Ribe wrote:
> 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:

My mistake for grabbing off the top of my head without testing my code.

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

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Filipe Pina 2015-04-03 14:35:14 Serializable transaction restart/re-execute
Previous Message John McKown 2015-04-03 14:09:19 Re: The case of PostgreSQL on NFS Server (II)