//情况一插入数据 select count(*) into num from table_name if num=0 insert table_name values(1,.......) else select max(id) from table_name put max into i insert table_name values(i+1,.......) //情况二update数据 定义cursor 定义变量i 定义变量count_num记录数据行数 select count(*) into count_num from table_name open cursor for(i=1,i=count_num,i++) update table_name set id=i where col2=@col2 col3=@col3 ...... //如果你有主键,where处用主键限制,否则从cursor读每条记录时,把每一列的数据做限制条件,应该有主键 close cursor 对不起,我长时间没有编程,具体的语句一定有错,但思路应该没错,请查语法书
select count(*) into num from table_name
if num=0
insert table_name values(1,.......)
else select max(id) from table_name
put max into i
insert table_name values(i+1,.......)
//情况二update数据
定义cursor
定义变量i
定义变量count_num记录数据行数
select count(*) into count_num from table_name
open cursor
for(i=1,i=count_num,i++)
update table_name
set id=i
where col2=@col2
col3=@col3
......
//如果你有主键,where处用主键限制,否则从cursor读每条记录时,把每一列的数据做限制条件,应该有主键
close cursor
对不起,我长时间没有编程,具体的语句一定有错,但思路应该没错,请查语法书