Home » SQL & PL/SQL » SQL & PL/SQL » create a sequence/primary key
create a sequence/primary key [message #20317] Mon, 13 May 2002 10:04 Go to next message
Godwin
Messages: 37
Registered: January 2002
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: create a sequence/primary key [message #20328 is a reply to message #20317] Mon, 13 May 2002 22:18 Go to previous message
vivek
Messages: 59
Registered: October 2001
Member
To do thsi through SQL seems really difficult but in PL/SQL a simpel procedure could do this quite easily. If u need any help in making teh procedure do let me know.
Previous Topic: Trigger Unhappy
Next Topic: sql query
Goto Forum:
  


Current Time: Fri May 03 22:26:32 CDT 2024