Oracle存储过程,以游标的方式返回一个记录集
--创建一个包
create or replace package types
as
type cursorType is ref cursor;
end types;
--创建存储过程,游标类型返回参数
create or replace procedure SP_Fee_Instance(v_company in varchar, v_sdate in nvarchar2, v_edate in nvarchar2,p_cursor in out types.cursorType) is
-- vs_sql varchar2(2000);
--company varchar2(100); --公司编码
--start_date varchar2(10); --计划付款时间段[起]
--end_date varchar2(10); --计划付款时间段[止]
begin
IF NVL(v_company,' ') <> ' ' THEN
OPEN p_cursor FOR
select a.company,a.pact_name,a.pact_code,i.payment_date,sum(i.payment_fee) as payment_fee,i.payment_condition,i.payment_remark
from htgl_pact_apply a
inner join htgl_fee_instance i on a.apply_id = i.apply_id
where a.payment_status=2
and a.company = v_company
and i.payment_date between to_date(v_sdate,'YYYY-MM-DD') and to_date(v_edate,'YYYY-MM-DD')
group by a.company,a.pact_name,a.pact_code,i.payment_date,i.payment_condition,i.payment_remark;
null;
-- dbms_output.put_line(company);
--
相关文档:
Oracle创建表时,常遇到先删除后创建的情况,而它又没有drop table... if exists语法。为此可以使用user_objects数据字典和动态sql语句实现类似的功能,如下所示:
create or replace procedure proc_dropifexists(
p_table in varchar2
) is
v_count number(10);
begin
&nbs ......
1.求部门中哪些人薪水最高:
select ename,sal
from emp join
(
select max(sal) max_sal, deptno
from emp
group by deptno
) t
on (emp.sal = t.max_sal and emp.deptno = t.deptno);
2.求部门平均薪水的等级:
select deptno, avg_sal, grade ......
Oracle 主要配置文件介绍:
profile文件,oratab 文件,数据库实例初始化文件 initSID.ora,监听配置文件, sqlnet.ora 文件,tnsnames.ora 文件
1.2 Oracle 主要配置文件介绍
1.2.1 /etc/profile 文件
系统级的环境变量一般在/etc/p ......
The following are number examples for the to_char function.
to_char(1210.73, '9999.9')
would return '1210.7'
to_char(1210.73, '9,999.99')
would return '1,210.73'
to_char(1210.73, '$9,999.00')
would return '$1,210.73'
to_char(21, '000099')
would return '000021'
The following is a list ......