urgently help required [message #83819] |
Mon, 15 December 2003 11:01 |
Vinod
Messages: 76 Registered: April 1999
|
Member |
|
|
I have a primary key column in the database and the requirement is to add values values like MS01,MS02,MS03.....
how do i do this by click of a button called ADD on the form.
i do not have a sequence for this in the backend
Thanks
Vinod
|
|
|
Re: urgently help required [message #83821 is a reply to message #83819] |
Mon, 15 December 2003 13:06 |
Praveen.B
Messages: 25 Registered: August 2002
|
Junior Member |
|
|
hi vinod ,
I think you requirement is to trap the numbers at the last and increment it by 1.Okay if it is so then you can use SUBSTR to remove the first two character MS and with the number left with you can add 1 to it and later concat with the removed character MS.I think this what you are expecting.
Regards
Praveen
|
|
|
Re: urgently help required [message #83859 is a reply to message #83821] |
Mon, 22 December 2003 01:38 |
sameer_am2002
Messages: 129 Registered: September 2002
|
Senior Member |
|
|
This practice is not very commonly used.Especially if your field is primary key.Coz char data take more query time then numeric data.Anyways this is how you can do it.Create a sequence then
declare
seqval number ;
begin
select test.nextval into seqval from dual ;
if length(seqval) > 1 then
:block.item:= 'MS'||seqval ;
else
:block.item := 'MS0'||seqval ;
end if ;
end ;
Try to put this code in Pre-Insert.So that your sequence is generated when the user really wants to insert record.
|
|
|