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

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 (view raw or flat)
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

pgsql-novice by date

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

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