Thread: Creating new table with a function?

Creating new table with a function?

From
Csányi Pál
Date:
Hi,

Is it possible to create a new table with help of a function?

I want to create a new table in my database by using a function that
get datas from existing tables so it can to create a new table with
fields.

Can one create such function?
If the answer is yes, then how can one do this?
Where is described in documentation creating such custom functions?

--
Regards from Pal


Re: Creating new table with a function?

From
Andreas Kretschmer
Date:
Csányi Pál <csanyipal@gmail.com> wrote:

> Hi,
>
> Is it possible to create a new table with help of a function?
>
> I want to create a new table in my database by using a function that
> get datas from existing tables so it can to create a new table with
> fields.
>
> Can one create such function?
> If the answer is yes, then how can one do this?
> Where is described in documentation creating such custom functions?

Sure, you can.

http://www.postgresql.org/docs/9.3/interactive/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN

40.5.4. Executing Dynamic Commands


Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect.                              (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly."   (unknown)
Kaufbach, Saxony, Germany, Europe.              N 51.05082°, E 13.56889°