Re: help with dynamic table name

From: "Jasbinder Singh Bali" <jsbali(at)gmail(dot)com>
To: "Peter Schonefeld" <peter(dot)schonefeld(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: help with dynamic table name
Date: 2007-03-06 04:27:15
Message-ID: a47902760703052027q35e451e4nbaa34eefd4f8cec5@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

try replacing double quotes with single quotes and you should be fine i
think
~Jas

On 3/5/07, Peter Schonefeld <peter(dot)schonefeld(at)gmail(dot)com> wrote:
>
> Hi, could someone please let me know what i'm doing wrong here?
>
> CREATE OR REPLACE FUNCTION sc_insert_row(char(32),text,varchar(32))
> RETURNS text AS $$
>
> DECLARE sql text;
> BEGIN
> sql := "INSERT INTO "+ $3 +" ('id','body') VALUES ("+ $1 +","+ $2 +")";
> EXECUTE sql;
> RETURN '';
> END;
>
> $$ LANGUAGE 'plpgsql' VOLATILE;
>
> I get the error: "ERROR: 42703: column \"INSERT INTO \" does not exist"
>
> Cheers
> Pete
>

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Peter Schonefeld 2007-03-06 04:36:38 Re: help with dynamic table name
Previous Message Peter Schonefeld 2007-03-06 03:59:48 help with dynamic table name