insert incremented value [message #641293] |
Thu, 13 August 2015 01:39 |
|
sanodani
Messages: 98 Registered: October 2014
|
Member |
|
|
Hallo,
I would like to insert the incremented value for one columm in the table. Can anyone please help me how can i do this?
test case:
create table m_test (
name varchar2(20),
oid number,
aid number,
bid number,
text varchar2(50),
c_text varchar2(20)
);
insert into m_test (name, oid, aid, bid, text, c_text) values('MAN', 11, 2, 2, 'Text for Testing', 'Maddy');
So, i would like to have the value for oid as 12 in next row and other coulum value will be provided, that somehow it need to check the previous value for oid and make increment by 1 and insert it.
Any help please?
Thankx
|
|
|
|
Re: insert incremented value [message #641297 is a reply to message #641293] |
Thu, 13 August 2015 02:21 |
pablolee
Messages: 2882 Registered: May 2007 Location: Scotland
|
Senior Member |
|
|
sanodani wrote on Thu, 13 August 2015 07:39
So, i would like to have the value for oid as 12 in next row and other coulum value will be provided, that somehow it need to check the previous value for oid and make increment by 1 and insert it.
Not really feasible in a multi-user environment. Your best bet is, (as LF has already said) use a sequence. You cannot guarantee contiguous values (no gaps) but you CAN guarantee the order of your data and with that, you can generate a contiguous set of numbers at query time if that is necessary.
|
|
|
|
|