help with dynamic table name

From: "Peter Schonefeld" <peter(dot)schonefeld(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: help with dynamic table name
Date: 2007-03-06 03:59:48
Message-ID: 9cc0d1180703051959n7a9beeafp5af897c7b5c41af9@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

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

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Jasbinder Singh Bali 2007-03-06 04:27:15 Re: help with dynamic table name
Previous Message WejofOST 2007-03-05 20:04:24 Help with creating Documentation