Creating tables from within functions - Mailing list pgsql-sql

From Saltsgaver, Scott
Subject Creating tables from within functions
Date
Msg-id 7283DE19D141D111AD0E00A0C95B195502488A93@mail2.aiinet.com
Whole thread Raw
List 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?

Thanks!

Scott Saltsgaver


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: Backup?
Next
From: "Bryan White"
Date:
Subject: Re: Backup?