Re: copy recursive data

From: Christoph Della Valle <christoph(dot)dellavalle(at)goetheanum(dot)ch>
To: "Petronenko D(dot)S(dot)" <petronenko(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: copy recursive data
Date: 2006-07-05 06:30:20
Message-ID: 44AB5C7C.1020803@goetheanum.ch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi

You are using double-quotes (") for varchar/char/text data type in your
example. This will not work - double-quotes are used to mark
columns/tables. You need them, if you use uppercase tablenames etc.
(not recommended!).

If I'm not mistaken you have to write a function (plpgsql/C/etc.) and
call this function.

hope, it helps,
chris

Petronenko D.S. schrieb:
> Hello,
>
> I have two tables. They are linked with foreign key. How can i copy row
> with all subrows into the same tables?
>
> For example, i have
>
> table1(id,title):
> 1,"title1".
>
> table2(id,table1_id,name):
> 1,1,"name1",
> 2,1,"name2",
> 3,1,"name3".
>
> I want to copy first row in table 1 and get following result:
> table1(id,title):
> 1,"title1",
> 2,"title1".
>
> table2(id,table1_id,name):
> 1,1,"name1",
> 2,1,"name2",
> 3,1,"name3",
> 4,2,"name1",
> 5,2,"name2",
> 6,2,"name3".
>
> How can i do this using sql queries from database side (not from
> application side)?
you can use pgAdmin or do it in the shell
And in general case table2 either can contain subrows
> from (for example) table3.
> Is it possible? and is solution is graceful?
>
> Thanks,
> Denis.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>
>

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Fabrice Franquenk 2006-07-05 09:29:55 Re: WAL Internals question
Previous Message Petronenko D.S. 2006-07-04 18:35:37 Re: copy recursive data