Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 97EB8477802 for ; Wed, 29 Jan 2003 03:18:55 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id CB65147749F for ; Wed, 29 Jan 2003 01:45:08 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 47A58D5FA; Tue, 28 Jan 2003 22:44:57 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 2F1A55C04; Tue, 28 Jan 2003 22:44:57 -0800 (PST) Date: Tue, 28 Jan 2003 22:44:57 -0800 (PST) From: Stephan Szabo To: Seethalakshmi VB Cc: Subject: Re: Creating tables from within functions In-Reply-To: Message-ID: <20030128224307.H4312-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/474 X-Sequence-Number: 11339 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.