Re: help with dynamic table name

Поиск
Список
Период
Сортировка
От Peter Schonefeld
Тема Re: help with dynamic table name
Дата
Msg-id 9cc0d1180703052036x5fbb6db8m90ae987ff3eca1bd@mail.gmail.com
обсуждение исходный текст
Ответ на Re: help with dynamic table name  ("Jasbinder Singh Bali" <jsbali@gmail.com>)
Ответы Re: help with dynamic table name  ("Jasbinder Singh Bali" <jsbali@gmail.com>)
Re: help with dynamic table name  ("Jasbinder Singh Bali" <jsbali@gmail.com>)
Re: help with dynamic table name  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
Список pgsql-novice
Hi Jas, thanks for the quick reply...I had started out with the single quotes, but had chaged it in my many efforts to get the thing to work...with the single quotes i'm getting the error:

"ERROR: 42883: operator does not exist: \"unknown\" + character varying"

====

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;


Pete



On 3/6/07, Jasbinder Singh Bali <jsbali@gmail.com> wrote:
try replacing double quotes with single quotes and you should be fine i think
~Jas

 
On 3/5/07, Peter Schonefeld <peter.schonefeld@gmail.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


В списке pgsql-novice по дате отправления:

Предыдущее
От: "Jasbinder Singh Bali"
Дата:
Сообщение: Re: help with dynamic table name
Следующее
От: "Jasbinder Singh Bali"
Дата:
Сообщение: Re: help with dynamic table name