Skip site navigation (1) Skip section navigation (2)

Re: help with dynamic table name

From: "Peter Schonefeld" <peter(dot)schonefeld(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: help with dynamic table name
Date: 2007-03-06 05:12:31
Message-ID: 9cc0d1180703052112o26fc8c2bs18a1b02a68dd5ec1@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-novice
Still no joy...if i forget about the variables and just try buidling a
string to execute, eg:

sql := 'INSERT INTO application (id,body) VALUES (''asdf'',''lkjh'')';

It works.

but with the variables i still get an error...

I tried putting quotes (two single quote chars) around the VALUES variables

  sql := 'INSERT INTO '+ $3 +' (id,body) VALUES ('''+ $1 +''','''+ $2
+''')';

but it still will not work. "ERROR: 42883: operator does not exist:
\"unknown\" + character varying"

Pete


On 3/6/07, Jasbinder Singh Bali <jsbali(at)gmail(dot)com> wrote:
>
>
> sql := 'INSERT INTO '+ $3 +' (id,body) VALUES ('+ $1 +','+ $2 +')';
> remove the double quotes with id and body and see if it works.
> ~Jas
>
> >
> >

In response to

Responses

pgsql-novice by date

Next:From: Peter SchonefeldDate: 2007-03-06 05:17:55
Subject: Re: help with dynamic table name
Previous:From: Stephan SzaboDate: 2007-03-06 05:00:04
Subject: Re: help with dynamic table name

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group