Re: computed values in plpgsql

From: Sam Mason <sam(at)samason(dot)me(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: computed values in plpgsql
Date: 2009-09-29 16:01:59
Message-ID: 20090929160159.GP5407@samason.me.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Sep 29, 2009 at 05:42:37PM +0200, Pavel Stehule wrote:
> you cannot use double quotes. It's not php.

Normally yes, but *inside* literals you do indeed want double quotes.

I think the OP wants to be using quote_literal here. I.e. instead of:

execute 'insert into foo_something select (''' || new::text || '''::foo).*';

it wants to be closer to:

execute 'insert into foo_something select (foo ' || quote_literal(new) || ').*;';

but it's a bit fiddly and I may have got that wrong somewhere else.

--
Sam http://samason.me.uk/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sam Mason 2009-09-29 16:04:37 Re: bulk inserts
Previous Message Alan Hodgson 2009-09-29 15:45:55 Re: bulk inserts