pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedCreating tables from within functions
4+ messages / 4 participants
[nested] [flat]
* Creating tables from within functions
@ 2000-06-27 16:17 Saltsgaver, Scott <scottsa@aiinet.com>
0 siblings, 0 replies; 4+ messages in thread
From: Saltsgaver, Scott @ 2000-06-27 16:17 UTC (permalink / raw)
To: 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
^ permalink raw reply [nested|flat] 4+ messages in thread
* Creating tables from within functions
@ 2003-01-24 08:36 Seethalakshmi VB <seethalakshmi.vb@majoris.com>
0 siblings, 1 reply; 4+ messages in thread
From: Seethalakshmi VB @ 2003-01-24 08:36 UTC (permalink / raw)
To: 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!
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Creating tables from within functions
@ 2003-01-29 06:44 Stephan Szabo <sszabo@megazone23.bigpanda.com>
parent: Seethalakshmi VB <seethalakshmi.vb@majoris.com>
0 siblings, 0 replies; 4+ messages in thread
From: Stephan Szabo @ 2003-01-29 06:44 UTC (permalink / raw)
To: Seethalakshmi VB <seethalakshmi.vb@majoris.com>; +Cc: 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.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Creating tables from within functions
@ 2003-01-29 08:16 Sondaar Roelof <roelof.sondaar@scania.com>
0 siblings, 0 replies; 4+ messages in thread
From: Sondaar Roelof @ 2003-01-29 08:16 UTC (permalink / raw)
To: 'Seethalakshmi VB' <seethalakshmi.vb@majoris.com>; pgsql-sql
Hello,
Try this:
CREATE FUNCTION _testcreate () RETURNS text AS '
BEGIN
CREATE TABLE switch_table2 (switch_id varchar(32),
selection_name varchar(100));
RETURN ''true'';
END;
' language 'plpgsql';
SELECT _testcreate();
Result:
snlsor=# SELECT _testcreate();
_testcreate
-------------
true
(1 row)
me=# \d
List of relations
Name | Type | Owner
----------------+----------+--------
switch_table2 | table | me
> -----Original Message-----
> From: Seethalakshmi VB [SMTP:seethalakshmi.vb@majoris.com]
> Sent: vrijdag 24 januari 2003 09:37
> To: pgsql-sql@postgresql.org
> Subject: [SQL] Creating tables from within functions
>
> 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!
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2003-01-29 08:16 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-06-27 16:17 Creating tables from within functions Saltsgaver, Scott <scottsa@aiinet.com>
2003-01-24 08:36 Creating tables from within functions Seethalakshmi VB <seethalakshmi.vb@majoris.com>
2003-01-29 06:44 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
2003-01-29 08:16 Re: Creating tables from within functions Sondaar Roelof <roelof.sondaar@scania.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox