Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Insert Statement Issues
I'm to add a record and am having problems
Assuming my table (cat) has
keyfield (number - primary), item_id (text - required)
insert into cat (keyfield, item_id) values (keyfieldvalue,'2001.25b')
the problem comes with the keyfielvalue, I need to increment the primary key by one. I tried the following
insert into cat (keyfield, item_id) values (max(keyfield)+1,'2001.25b') insert into cat (keyfield, item_id) values ((select max(keyfield)+1 from cat),'2001.25b')
ORA-00936: missing expression
If I trade the max query for a straight out number it works fine
insert into cat (keyfield, item_id) values (1457,'2001.25b')
So how do I get the largest value in the table at present and then use it in my statement ?
-- James StarrittReceived on Mon Jun 25 2001 - 12:15:58 CDT