| From: | AGRE Enterprises <agree(at)godzone(dot)net(dot)nz> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Need help with db procedure |
| Date: | 1998-10-13 01:02:38 |
| Message-ID: | 199810130102.OAA12852@agree-2.godzone.net.nz |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
I am trying to work out whether what I want to do is even possible. If it
is, how does one do it.
I wish to insert a row into table x. One of the columns has been a varchar
but examining the data has shown that of the 350,000 rows, there are only
18,000 unique values for the column. What I want to do is to put those
18,000 values in another table and replace the column in my table x by a
key into the new table.
I want the new insert to look something like this.
insert into table x values (
'aaa','bbb', key_of( "abcdefghijkl" ) );
I want the key_of function to either return the appropriate key if the
parameter is already in the other table, or create a new row and return
its key if it isn't.
I am struggling to work out how to do this as sql doesn't seem to support
an 'if'.
Any help appreciated.
PS: I am not currently subscribed to the list so can you cc: or reply
to me directly. Thanks.
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Glen Eustace, on behalf of
GodZone Internet Services, a division of AGRE Enterprises Limited
176 Te Awe Awe Street, Palmerston North, New Zealand
Ph: +64 6 356 2562, Fax: +64 6 357 0271
http://www.godzone.net.nz, EMail: agree(at)godzone(dot)net(dot)nz, ICQ: 10397208
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
| From | Date | Subject | |
|---|---|---|---|
| Next Message | ZioBudda | 1998-10-13 12:33:46 | some questions |
| Previous Message | Rick Dearman | 1998-10-12 22:10:47 | (no subject) |