Re: Duplicating rows in one table but with one column value - Mailing list pgsql-general

From Anastasios Hatzis
Subject Re: Duplicating rows in one table but with one column value
Date
Msg-id 44F892DD.9080401@gmx.net
Whole thread Raw
In response to Duplicating rows in one table but with one column value different  (Anastasios Hatzis <ahatzis@gmx.net>)
List pgsql-general
Anastasios Hatzis wrote:
>
> rows = plpy.execute("""SELECT "FooHolding" WHERE "CoosOfFoo_vid" =
> ORIGINALVALUE;""")
> for row in rows:
>    for col in row:
>        plpy.execute("""INSERT INTO "FooHolding" ("CoosOfFoo_eid",
> "CoosOfFoo_vid", "FoosOfCoo_eid", "FoosOfCoo_vid") VALUES (col[0],
> COPYVALUE, col[2], col[3]);""")
>
Well, I want to fix my given code example, although I guess, the idea is
obvious ;-)

rows = plpy.execute("""SELECT * FROM "FooHolding" WHERE "CoosOfFoo_vid"
= ORIGINALVALUE;""")
for row in rows:
    plpy.execute("""INSERT INTO "FooHolding" ("CoosOfFoo_eid",
"CoosOfFoo_vid", "FoosOfCoo_eid", "FoosOfCoo_vid") VALUES (row[0],
COPYVALUE, row[2], row[3]);""")


Sorry,

Anastasios

pgsql-general by date:

Previous
From: David Fetter
Date:
Subject: Re: number of elements in a multidimensional array
Next
From: Randall Lucas
Date:
Subject: Re: Dependency graph of all tuples relied upon in a query answer