oracle存储过程

create or replace procedure pro_test(c1 in t_co_consignment.id%type)
AS var1 number:=5;
   var2 number;
   var3 boolean;
     cursor cur(tnt_like varchar2) is select c.id from t_co_consignment c where
     c.tnt_barcode like tnt_like||'%';--||连接运算符 
begin
 
      --for cur_result in cur('080407001000') loop
      
      open cur('080407001000');
      LOOP
      FETCH cur INTO var2;
      EXIT WHEN cur%NOTFOUND;
      begin
           dbms_output.put_line(var2);
      end;
     end loop;
     close cur;
    -- dbms_output.put_line(SQL%rowcount);
    
  --  IF c1 != -1 THEN
  --     BEGIN
   --       dbms_output.put_line(c1);  
   --    END;
   --  END IF;
     
    WHILE var1 !=to_number(-1) LOOP
      BEGIN
          dbms_output.put_line(var1); 
           var1:=var1-1;
      END;
    END LOOP;
    
    var3:=check_odd_number(c1);
    if var3 then
    dbms_output.put_line('true'); 
    else
    dbms_output.put_line('false'); 
    end if;
    EXCEPTION 
    WHEN no_data_found THEN
    dbms_output.put_line('no date found');
    WHEN others THEN
    rollback;
    dbms_output.put_line('some unexcept exception occur');
    return;

end pro_test;



sql台输入set serveroutput on 则输出put_line;

create or replace function check_Odd_Number(var1 number)
return boolean 
is
v_return boolean;
begin
    if mod(var1,2)=1 then
      v_return:= true;
    else
      v_return:= false;
    end if;
    dbms_output.put_line('function end');
    return v_return;
end check_Odd_Number;

你可能感兴趣的:(oracle,sql,C++,c,C#)