update tableA a
set (a.col1,a.col2,a.seqid)
=(
select B.col1,B.col2,seq_sino_id.nextval
from tableB b
where a.fid = b.fid 
)
where a.seqid  is null;
这里面的seq_sino_id 是一个序列编译时会报错:此处不充许序号。
------------------------------请问大侠们这个语句要怎么改才能达到目的?

解决方案 »

  1.   

    update tableA a
    set (a.col1,a.col2,a.seqid)
    =(
    select B.col1,B.col2,rownum
    from tableB b
    where a.fid = b.fid  
    )
    where a.seqid is null;
      

  2.   

    这里更新的值必须要是从seq_sino_id来的,用rownum不能代替,否则后面业务会出错。
      

  3.   

    怎么个单独赋值法? 我是担心如果我是分两次将col1,col2和seqid更新进去的话会有问题,也就是说col1,col2和seqid的值必须是同时出现才行。
      

  4.   

    从你写的sql上看,分两次应该不会有问题吧,如果担心事务的问题,可用两次执行都完成后,再提交。
      

  5.   

    --比如说你序列的初始值是1000 步长是2的话
    update tableA a
    set (a.col1,a.col2,a.seqid)
    =(
    select B.col1,B.col2,1000+rownum*2 --这个不就相当于序列了吗?
    from tableB b
    where a.fid = b.fid  
    )
    where a.seqid is null;
      

  6.   

    先谢过这位仁兄,这个seq_sino_id是没办法代替的,因为它不只是在这个语句里使用了,而且在另外的语句中也有使用,是没法用rownum模拟出来的。