阅读背景:

使用PL/SQL创建,测试Oracle存储过程

来源:互联网 

首先在左侧的文件夹当选中procedures文件夹,新建一个存储进程,以下:

create or replace procedure uc_users_amount_pro(endDate in varchar2) 
is

  insMember    number;
  perMember    number;
  insMemberMon number;
  perMemberMon number;

--  变量名    表名.字段名%type;

--  rowtype表现该类型为行数据类型,存储的是一行数据,一行数据里可以有多列,相似于表里的一行数据,也能够是游标里的一行数据,如:
--  vs_row1  表%rowtype;
--  vs_row2  游标%rowtype;

--  CURSOR 游标名 [( 参数 in type)] IS
--  Select 语句

begin
  select count(*)
    into insMember
    from uc_users u, uc_form f
   where u.form_id = f.id
     and f.form_cn = "企业会员"
     and u.gmt_create < to_timestamp(endDate,"yyyy-mm-dd");
  select count(*)
    into perMember
    from uc_users u, uc_form f
   where u.form_id = f.id
     and f.form_cn = "个人会员"
     and u.gmt_create < to_timestamp(endDate,"yyyy-mm-dd");
  select count(*)
    into insMemberMon
    from uc_users u, uc_form f
   where u.form_id = f.id
     and f.form_cn = "企业会员"
     and to_char(u.gmt_create, "yyyy-mm") =
         to_char(to_timestamp(endDate, "yyyy-mm-dd"), "yyyy-mm");
  select count(*)
    into perMemberMon
    from uc_users u, uc_form f
   where u.form_id = f.id
     and f.form_cn = "个人会员"
     and to_char(u.gmt_create, "yyyy-mm") =
         to_char(to_timestamp(endDate, "yyyy-mm-dd"), "yyyy-mm");
  dbms_output.put_line(insMember || " " || perMember || " " ||
                       insMemberMon || "" || perMemberMon);
end uc_users_amount_pro;create or 




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: