pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
create tables within functions
3+ messages / 3 participants
[nested] [flat]

* create tables within functions
@ 2003-06-13 15:07 Demidem Mohamed Amine <demidem_amine@yahoo.com>
  2003-06-13 15:22 ` Re: create tables within functions Stephan Szabo <sszabo@megazone23.bigpanda.com>
  2003-06-13 19:15 ` Re: create tables within functions chester c young <chestercyoung@yahoo.com>
  0 siblings, 2 replies; 3+ messages in thread

From: Demidem Mohamed Amine @ 2003-06-13 15:07 UTC (permalink / raw)
  To: pgsql-sql

hello,

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

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



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: create tables within functions
  2003-06-13 15:07 create tables within functions Demidem Mohamed Amine <demidem_amine@yahoo.com>
@ 2003-06-13 15:22 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Stephan Szabo @ 2003-06-13 15:22 UTC (permalink / raw)
  To: Demidem Mohamed Amine <demidem_amine@yahoo.com>; +Cc: 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
>




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: create tables within functions
  2003-06-13 15:07 create tables within functions Demidem Mohamed Amine <demidem_amine@yahoo.com>
@ 2003-06-13 19:15 ` chester c young <chestercyoung@yahoo.com>
  1 sibling, 0 replies; 3+ messages in thread

From: chester c young @ 2003-06-13 19:15 UTC (permalink / raw)
  To: Demidem Mohamed Amine <demidem_amine@yahoo.com>; +Cc: pgsql-sql

--- Demidem Mohamed Amine <demidem_amine@yahoo.com> wrote:
> hello,
> 
> Can anyone help me create a function that creates a table:

create function create_table( text ) returns integer as '
declare
  p_tab alias for $1;
  v_exec text;
begin
  v_exec := ''create table '' || p_tab || ''( id integer )'';
  execute v_exec;
end;
' language 'plpgsql'; 



__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2003-06-13 19:15 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-06-13 15:07 create tables within functions Demidem Mohamed Amine <demidem_amine@yahoo.com>
2003-06-13 15:22 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
2003-06-13 19:15 ` chester c young <chestercyoung@yahoo.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox