function to create a table

From: diana(at)softwaresolutions(dot)ro
To: pgsql-general(at)postgresql(dot)org
Subject: function to create a table
Date: 2001-03-30 06:09:30
Message-ID: 200103300609.f2U69Uf16249@softwaresolutions.ro
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Good day,
I have a problem with plpgsql, whitch is really strange for me.
I wanna create a table, with a function like this :

CREATE FUNCTION domenii(text,text,text)
RETURNS boolean
AS 'DECLARE
legi ALIAS FOR $2;
BEGIN
CREATE TABLE legi(idc serial, idp char(10), nume char(50), PRIMARY
KEY(idc));
RETURN ''t'';
END;'
LANGUAGE 'plpgsql';

the error message from psql is :

select domenii('gigi','gigi1','gigi2');
ERROR: parser: parse error at or near "$1"

and the postgres error message is

010330.08:16:53.385 [9931] ERROR: parser: parse error at or near "$1"
010330.08:16:53.385 [9931] DEBUG: Last error occured while executing
PL/pgSQL function domenii
010330.08:16:53.386 [9931] DEBUG: line 4 at SQL statement

my question is.
Why is asking me about $1 wenn i don't have this in my function, it seems to be a problem with create table.
Thanks you very much.

Diana Cionoiu

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Lockhart 2001-03-30 06:22:21 Re: [PATCHES] Error in the date field (with NULL value...).Thanks!
Previous Message datactrl 2001-03-30 05:36:49 PostGreSQL 7.1