Need a sample Postgre SQL script

From: "Dhanushka Samarakoon" <dhanu80(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Need a sample Postgre SQL script
Date: 2008-07-01 14:31:54
Message-ID: 93e317cd0807010731o7655a1d5j76c6bb2482cea910@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi All,

I'm kind of new to Postgre and I need some advice.
I have the following table.
metadata (value:integer , field:integer , mydate:text)

given below is a sample record from that.
( 2 , 16 , Augest 2009)

I need a script that will read the above table and for each such row it will
insert two rows as below.

( 2 , 91 , Augest )
( 2 , 86 , 2009 )

16, 91 and 86 are static values. *value and field together* creates the
primary key.

I could figure out and write the logic for this. I only need a little bit
similar sample script so that I can figure out Postgre syntax.
Like
- Loop syntax to through all the rows return by a select *
- How to assign that value to a parameter
- using that parameter in the Insert statement
- etc ...

Thanks,
Dhanushka.

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Huxton 2008-07-01 14:42:48 Re: Need a sample Postgre SQL script
Previous Message Gary Stainburn 2008-07-01 12:42:14 Re: Quick select, slow update - help with performance problems