Creating tables from within functions

From: "Seethalakshmi VB" <seethalakshmi(dot)vb(at)majoris(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Creating tables from within functions
Date: 2003-01-24 08:36:31
Message-ID: MCBBKKFNMOLJEPPNKICGCEABCAAA.seethalakshmi.vb@majoris.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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
simply not possible to create a table from within a function?

Please give me the reply soon as possible
Thanks!

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tambet Matiisen 2003-01-24 08:39:26 Re: calling function from rule
Previous Message Chris Gamache 2003-01-24 07:58:54 Race condition w/ FIFO Queue reappears!