Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Sql > Re: Need a samp...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 5 Topic 3555 of 3797
Post > Topic >>

Re: Need a sample Postgre SQL script

by dev@[EMAIL PROTECTED] (Richard Huxton) Jul 1, 2008 at 03:42 PM

Dhanushka Samarakoon wrote:
> Hi All,
> 
> I'm kind of new to Postgre and I need some advice.

No problem. It's PostgreSQL or Postgres by the way.

> 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.

CREATE TEMP TABLE staticfields (f integer);
INSERT INTO staticfields VALUES (91);
INSERT INTO staticfields VALUES (86);

INSERT INTO metadata (value, field, mydate)
SELECT value, f, mydate
FROM metadata, staticfields;

-- 
   Richard Huxton
   Archonet Ltd

-- 
Sent via pgsql-sql mailing list (pgsql-sql@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
 




 5 Posts in Topic:
Need a sample Postgre SQL script
dhanu80@[EMAIL PROTECTED]  2008-07-01 09:31:54 
Re: Need a sample Postgre SQL script
dev@[EMAIL PROTECTED] (R  2008-07-01 15:42:48 
Re: Need a sample Postgre SQL script
dhanu80@[EMAIL PROTECTED]  2008-07-01 09:53:02 
Re: Need a sample Postgre SQL script
dev@[EMAIL PROTECTED] (R  2008-07-01 16:17:30 
Re: Need a sample Postgre SQL script
dhanu80@[EMAIL PROTECTED]  2008-07-02 12:12:37 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Dec 1 11:19:13 CST 2008.