oralce存储过程

--存储过程 %type类型
declare
  v_name g_cs_customer.enterprise%type;
  v_qty B_OD_ORDERMASTER_BJ.Totaldefqty%type;
  v_amt B_OD_ORDERMASTER_BJ.Totalamt%type;
  v_cust g_cs_customer%rowtype;
begin
  select b.enterprise,a.totaldefqty,a.totalamt into v_name,v_qty,v_amt   
  from B_OD_ORDERMASTER_BJ a inner join g_cs_customer b on 
  a.customersid=b.customersid where b.licensecode='110105******';
  Dbms_Output.put_line('店名:'||v_name||'条数:'||v_qty||'金额:'||v_amt);
  select * into v_cust from g_cs_customer a where a.licensecode='110105******';
  Dbms_Output.put_line('地址:'||v_cust.address);
  
end;

--存储过程 %rowtype类型
declare
  v_name g_cs_customer.enterprise%type;
  v_qty B_OD_ORDERMASTER_BJ.Totaldefqty%type;
  v_amt B_OD_ORDERMASTER_BJ.Totalamt%type;
  v_cust g_cs_customer%rowtype;
begin
  select b.enterprise,a.totaldefqty,a.totalamt into v_name,v_qty,v_amt   
  from B_OD_ORDERMASTER_BJ a inner join g_cs_customer b on 
  a.customersid=b.customersid where b.licensecode='110105******';
  Dbms_Output.put_line('店名:'||v_name||'条数:'||v_qty||'金额:'||v_amt);
  select * into v_cust from g_cs_customer a where a.isactive='1';
  Dbms_Output.put_line('地址:'||v_cust.address);
--异常处理
  exception
    when no_data_found then 
  dbms_output.put_line('未查找到任何数据');
      when too_many_rows then 
  dbms_output.put_line('返回多行数据');
end;

--条件判断
declare
  v_name g_cs_customer.enterprise%type;
  v_qty B_OD_ORDERMASTER_BJ.Totaldefqty%type;
  v_amt B_OD_ORDERMASTER_BJ.Totalamt%type;
  v_cust g_cs_customer%rowtype;
begin
 select b.enterprise,a.totaldefqty into v_name,v_qty from B_OD_ORDERMASTER_BJ a
  inner join g_cs_customer b on a.customersid=b.customersid where b.licensecode='110105******';
 if v_qty<=20 then   dbms_output.put_line('小于20');
 elsif  v_qty<=50  then  dbms_output.put_line('20-50');
 else dbms_output.put_line('大于50') ;
   end if;
  exception
    when no_data_found then 
  dbms_output.put_line('未查找到任何数据');
      when too_many_rows then 
  dbms_output.put_line('返回多行数据');
end;


最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。