View previous topic :: View next topic
|
Author |
Message |
rashmi.ranjan75
New User
Joined: 20 Feb 2006 Posts: 34
|
|
|
|
Hi,
I have a table T1 with following fields
SEQ NUM,
NAME
SEQ NUM is primary key of the table.
I have some records in T1 with name M1.
I want to write
insert into T1
(SEQ NUM,
NAME)
SELECT
(select max(SEQ NUM)+1 from T1),
M2)
This query is not working because of the subquery which i have used to increase the SEQ NUM.
Could any one suggest how to do this insert?
any ideas plz
Regards
Rashmi |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
Your looking to insert a single record with this SQL execution? (Not multiple records incrementing seq_num)? |
|
Back to top |
|
|
rashmi.ranjan75
New User
Joined: 20 Feb 2006 Posts: 34
|
|
|
|
there are mulitple records |
|
Back to top |
|
|
wanderer
Active User
Joined: 05 Feb 2007 Posts: 199 Location: Sri Lanka
|
|
|
|
rashmi.ranjan75 wrote: |
SELECT
(select max(SEQ NUM)+1 from T1),
M2)
|
So what is the error you are getting? It would be helpful to paste it here.
To me it seems that there is no FROM clause in your select. May be you can add one "from sysibm.sysdummy1". |
|
Back to top |
|
|
rashmi.ranjan75
New User
Joined: 20 Feb 2006 Posts: 34
|
|
|
|
sql error code coming is -4700 and sqlstate is 56038
the actual query is
insert into T1
(SEQ NUM,
NAME)
SELECT
(select max(SEQ NUM)+1 from T1),
M2)
from
T1;
Thanks to see if it is possible somehow |
|
Back to top |
|
|
vini_srcna
Active User
Joined: 26 May 2005 Posts: 178 Location: Copenhagen, Denmark
|
|
|
|
Try this query,This should work
insert into T1 (SEQ NUM, NAME)
SELECT max(SEQ NUM)+1,'M2' from T1 ; |
|
Back to top |
|
|
|