f*******f 发帖数: 12 | 1 What I want to do is something like that:
declare @id
select @id=max(id) from mytable
if(@id is null)
@id=0
else
@id=@id+1
insert into mytable(@id,'aa','bbb')
But How to synchronized it when multiple connetions access database.
I use JDBC..
Thank you | B**z 发帖数: 153 | 2 I think you are trying to generate sequence for primary key for mytable
you can just declare the id column as identity. when you insert into
you just values('aa','bb')
【在 f*******f 的大作中提到】 : What I want to do is something like that: : declare @id : select @id=max(id) from mytable : if(@id is null) : @id=0 : else : @id=@id+1 : insert into mytable(@id,'aa','bbb') : But How to synchronized it when multiple connetions access database. : I use JDBC..
| f*******f 发帖数: 12 | 3 Thank you. I got it.
【在 B**z 的大作中提到】 : I think you are trying to generate sequence for primary key for mytable : you can just declare the id column as identity. when you insert into : you just values('aa','bb')
|
|