select count(rowid) into nCnt from 表名 where 号码 like '0106330%'
if nCnt > 0 then return 0;
return 1;

解决方案 »

  1.   

    create or replace function f_is_in_str(in_str varchar2) return number as
    v_ret number(5);
    begin
       select count(*) into v_ret from 表名 where instr(phone,in_str)>0;
       if v_ret > 0 then return 0;
       return 1;
    end;
    /
      

  2.   

    其实一句sql就可以了
    select case when count(*)=0 then 0 else 1 end from phone where instr( phone,'010' ) >0;
    //用存储过程也可以这样
    create or replace procedure f_is_in_str(in_str in varchar2,Rst out integer) 
    is
    begin
    select case when count(*)=0 then 0 else 1 end into Rst from phone where instr( phone,'010' ) >0;
    end;
      

  3.   

    CREATE OR REPLACE procedure myproc( id in varchar2,  returnStr out varchar2)
    is
    begin
    select count(haoma) into returnStr from phone where id like '0106330%';
    if returnStr > 0 then
       returnStr:='0';
    else
       returnStr:='1';
    end if;
    dbms_output.put_line(returnStr);
    end; 
    我现在这样能实现,我现在想去掉id最后的一位判断是否和0106330相等
    该怎么改SQL语句 ?
      

  4.   

    CREATE OR REPLACE procedure myproc( id in varchar2, returnStr out varchar2)
    is
    begin
    select count(haoma) into returnStr from phone where substr(id,1,length(id)-1)= '0106330';
    if returnStr > 0 then
    returnStr:='0';
    else
    returnStr:='1';
    end if;
    dbms_output.put_line(returnStr);
    end;