Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 63F3147605C for ; Fri, 24 Jan 2003 04:07:45 -0500 (EST) Received: from canopus.majoris.com (unknown [164.164.88.66]) by postgresql.org (Postfix) with ESMTP id 55102476723 for ; Fri, 24 Jan 2003 03:38:14 -0500 (EST) Received: (from root@localhost) by canopus.majoris.com (8.10.2+Sun/8.10.2) id h0O8Ypc12603 for ; Fri, 24 Jan 2003 14:04:51 +0530 (IST) Received: from nodnsquery(172.20.10.5) by canopus.majoris.com via csmap (2.0) id srcAAAaRaqNy; Fri, 24 Jan 03 14:04:50 +0530 Received: from seethalakshmi ([172.20.10.199]) by electra.majoris.com (Netscape Messaging Server 4.15) with SMTP id H97MLY00.RBD for ; Fri, 24 Jan 2003 14:07:10 +0530 From: "Seethalakshmi VB" To: Subject: Creating tables from within functions Date: Fri, 24 Jan 2003 14:06:31 +0530 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/469 X-Sequence-Number: 11334 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!