Re: Creating tables from within functions

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Seethalakshmi VB <seethalakshmi(dot)vb(at)majoris(dot)com>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Creating tables from within functions
Date: 2003-01-29 06:44:57
Message-ID: 20030128224307.H4312-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


On Fri, 24 Jan 2003, Seethalakshmi VB wrote:

> Is it possible to issue a CREATE TABLE statement from inside of a PostgreSQL
> function? If not, then how about from within a PL/pgSQL function? I have
> tried a lot of different permutations but can't seem to get it to compile
> and/or run cleanly. For example, consider:
>
> CREATE FUNCTION _testcreate () RETURNS text AS '
> BEGIN
> CREATE TABLE switch_table2 (switch_id varchar(32),
> selection_name varchar(100));
> end;
> ' language 'plpgsql';
>
> What is wrong with this? What type should be returned? Or perhaps it is

Well you have no return value. Once I put one in it works for me.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Abdul Wahab Dahalan 2003-01-29 07:27:18 USING INDEX
Previous Message Stephan Szabo 2003-01-29 06:13:59 Re: Cross-table constraints