Re: Duplicating rows in one table but with one column value

From: Anastasios Hatzis <ahatzis(at)gmx(dot)net>
To: PostgreSQL general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Duplicating rows in one table but with one column value
Date: 2006-09-01 20:06:53
Message-ID: 44F892DD.9080401@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Joshua D. Drake 2006-09-01 20:35:07 Re: Training (from Thought provoking...)
Previous Message David Fetter 2006-09-01 18:47:37 Re: number of elements in a multidimensional array