Re: create tables within functions

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Demidem Mohamed Amine <demidem_amine(at)yahoo(dot)com>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: create tables within functions
Date: 2003-06-13 15:22:42
Message-ID: 20030613082154.M62271-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Fri, 13 Jun 2003, Demidem Mohamed Amine wrote:

> hello,
>
> Can anyone help me create a function that creates a
> table, in this way for example :

See EXECUTE for a way to execute a query that you've built into
a string, for example, something like:

EXECUTE ''create table '' || $1 || '' (id integer, stuff text)'';

>
> create function create_table(text) returns integer as
> '
> begin
> create table $1 (id integer, stuff text);
> return 0;
> end;'
> language plpgsql;
>
> it does not work !!
>
> thnx
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
> http://calendar.yahoo.com
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Jan Wieck 2003-06-13 16:30:27 Re: question on rules
Previous Message Demidem Mohamed Amine 2003-06-13 15:07:43 create tables within functions