generating sequence/primary key based on dept (a column)type [message #38764] |
Mon, 13 May 2002 11:06 |
Amarsey
Messages: 17 Registered: March 2002
|
Junior Member |
|
|
Please help me with this problem given to me by my boss.
''I need to create sequence/primary key which will pick the first 4 characters of a column called dept and count the number of records in that same dept to generate the p.k. the sequence must restart at every new dept. eg.
select dept,grade from staffrecord
insert into mytable
values (dept,grade,seq)
Thus the records in mytable should look like
Zoology Senior Clerk ZOOL001
Zoology Junior Clerk ZOOL002
Mathematics Lecturer MATH001
Mathematics T.A MATH002
............ ..... ......
in that order.
Will plsql rather be okay?
Thanks
|
|
|
Re: generating sequence/primary key based on dept (a column)type [message #38767 is a reply to message #38764] |
Mon, 13 May 2002 12:02 |
Rick Cale
Messages: 111 Registered: February 2002
|
Senior Member |
|
|
Hi,
I hate to sound cynical but PLEASE send your boss to
data modeling 101. This is absolutely a terrible approach. A sequence is fine but not based on your data. Try providing alternative solutions to your boss
before trying to implement this mess. I know this does not address your question but I really think you
should strive for the proper design it will save everyone in the future.
|
|
|