日期:2014-05-16  浏览次数:20978 次

oracle存储过程如何写
需求是统计当前公司下的用户总数:公司表tbl_organization,用户表tbl_users,公司表的id为用户表的org_id,现需要展现所有公司下的用户总数,所以感觉需要写一个存储过程重新建一个表来存储对应公司下的用户总数,但没有写过存储过程,特请各位朋友帮忙写一个,谢谢了
这是一个根据公司id查询该公司下用户总数的sql语句,供各位朋友参考:
SQL code

select count(*) from tbl_users u where u.id>0 and u.org_id in (
       select org.id from tbl_organization org where org.deleted=0 
       start with org.id in (20776) connect by nocycle prior org.id=org.org_parent_id ) 
and u.deleted=0



------解决方案--------------------
探讨

引用:
create or replace procedure proc_name
is begin

create table tbl_new as select a.id,a.org_name,nvl(count(b.org_id),0) countUser from tbl_organization a left join tbl_users b
on a.id……