请教 当输入的id号在表中不存在则返回信息“此ID不存在”的存储过程如何实现?

解决方案 »

  1.   

    if (select count(*) from table where id='001')=0
       return '此ID不存在'
      

  2.   

    后台存储过程中设置一个输出参数
    create or replace produce pro_test(
              .......
              var_output   varchar2   )
    as 
           ...........
           i   number(10);
    begin
           ...........
           select count(*) into i
           from   table 
           where  id='xxx';
           if i = 0 then
              var_output:='此ID不存在';
              return;
           edn if;
           ............
    end;在前台在执行到这个存储过程时候输出这个参数就行了!
      

  3.   

    create procedure checkid(@id int,@returnstr varchar(20) output)as 
    ...
      if not exists(select * from table where id=@id )
      begin
        set @returnstr='此ID不存在'
        return 0
      end
    ...
    go
      

  4.   

    edit1.text:=adostroproc.params[1].value;//1为参数序号
      

  5.   

    edit1.text:=adostroproc.params[1].value;//1为参数序号