create proc sp_nextno @preno varchar(14)
as
select incno+1 as intt from nextno where preno = @preno
begin tran tran_nextno
  update nextno set incno = incno+1 where preno = @preno
  if @@error<>0
    begin
      rollback tran Tran_nextno
      return -1000
    end
  else
    begin
      commit tran Tran_nextno
      return 0
    end
GO
我这样的存储过程可以得到返回值吗?
我想得到select出来的值,用ADOStoredProc怎么写呀????????????

解决方案 »

  1.   

    只是update一个表个人认为不用开事务吧
    学习
    create proc sp_nextno @preno varchar(14)
    as
    begin
      select incno+1 as intt from nextno where preno = @preno
      begin tran tran_nextno
      update nextno set incno = incno+1 where preno = @preno
      if @@error<>0 goto error_update
      commit tran Tran_nextno
      return 0
    end
    error_update:
          rollback tran Tran_nextno
          return -1000
      

  2.   

    有返回值,return的是执行存储过程得到的结果
    select得到你要的数据集
      

  3.   

    可以在存储过程中定义一个输出参数aa,然后就可以直接用了
    result := ADOStoredProc1.Parameters.Parambyname('@newlist_no').value;
      

  4.   

    http://community.csdn.net/Expert/TopicView.asp?id=3130478
      

  5.   

    Parameters.ParamByName('@RETURN_VALUE').Value也是可以的