1、pro1:
CREATE OR REPLACE PROCEDURE fojian_oneParam(
rCursor OUT SYS_REFCURSOR,
numberVarchar varchar2,
textVarchar varchar2,
justNumber varchar2,
justDate date,
param_type char,
mutil_select char
) AS
v_sql varchar2(500);
e_exception exception;
BEGIN
--insert into test_proc(area_id_v,sale,start_time,end_time) values(area_id_v,sale,start_time,end_time);
--commit;
v_sql:='select area_id_v 地区编号 ,area_name 地区名称 ,sale 销售额 ,profit 利润,showtime 统计时间 from fj_test where 1=1';
--param_type 为返回类型;
--00为number型字符;01为文本型字符;1为number型;2为日期型字符;3为数字、字符、日期的综合类型
--mutil_select 是否使用in查询 0为单选;1为多选;
IF param_type = '00' AND numberVarchar IS NOT NULL THEN
IF mutil_select ='0' THEN
v_sql := v_sql || ' and area_id_v ='''|| numberVarchar ||'''';
END IF;
IF mutil_select ='1' THEN
v_sql :=v_sql || ' and area_id_v in (''' || replace(numberVarchar,',',''',''') || ''')';
END IF;
END IF;
IF param_type = '01' AND textVarchar IS NOT NULL THEN
IF mutil_select ='0'THEN
v_sql := v_sql || ' and area_name =''' || textVarchar ||'''';
END IF;
IF mutil_select ='1' THEN
v_sql :=v_sql || ' and area_name in (''' || replace(textVarchar,',',''',''') || ''')';
END IF;
END IF;
IF param_type = '1' AND justNumber IS NOT NULL THEN
IF mutil_select ='0'THEN
v_sql := v_sql || ' and sale >' || justNumber;
END IF;
IF mutil_select ='1' THEN
v_sql :=v_sql || ' and sale in (' || justNumber || ')';
END IF;
END IF;
IF param_type = '2' AND justDate IS NOT NULL THEN
v_sql := v_sql || ' and showtime >= ''' || justDate || '''';
END IF;
IF param_type = '3' AND justDate IS NOT NULL THEN
IF numberVarchar is not null THEN
v_sql := v_sql || ' and area_id_v in (''' || replace(numberVarchar,',',''',''') || ''')';
END IF;
IF justNumber is not null THEN
v_sql := v_sql || ' and sale >=' || justNumber;
END IF;
v_sql := v_sql || ' and showtime >= ''' || justDate || '''';
END IF;
IF numberVarchar = '19970101' THEN
RAISE e_exception;
END IF;
--insert into testpro values(v_sql);
--commit;
dbms_output.put_line(v_sql);
--dbms_output.put_line(justDate);
open rCursor for v_sql;
EXCEPTION
WHEN e_exception THEN
--INSERT INTO log_table (info) VALUES (e_exception);
open rCursor for 'select area_id_v ,area_name ,sale,profit,showtime from fj_test';
WHEN OTHERS THEN
insert into log_table (info) values ('Another error occurred');
END fojian_oneParam;
2、create procedure with package
CREATE OR REPLACE PACKAGE fojian
AS
TYPE myrctype IS REF CURSOR;
PROCEDURE getFojian (p_id in varchar2, p_rc OUT myrctype);
END fojian;
CREATE OR REPLACE PACKAGE BODY fojian
AS
PROCEDURE getFojian (p_id in varchar2, p_rc OUT myrctype)
IS
sqlstr VARCHAR2 (500);
BEGIN
IF p_id is null THEN
OPEN p_rc FOR
SELECT *
FROM fj_test;
ELSE
sqlstr :=
'select *
from fj_Test where area_id=:p_id';
OPEN p_rc FOR sqlstr USING p_id;
END IF;
END getFojian ;
END fojian;
3、create table with procedure
create table fj_test_rpt(statdate date,
userid varchar2(20),
area_id_v varchar2(10),
area_id_n number(10),
areaname varchar2(20),
outcome_dazong number(38,6),
income_dazong number(38,6),
outcome_shenzhou number(38,2),
income_shenzhou number(38,2),
outcome_donggan number(38),
income_donggan number(38)
);
declare
begin
for i in 1..20 loop
for j in 1..50 loop
insert /*+APPEND*/ into fj_test_rpt select
(sysdate+i)+j/24/3600,
'fojian',
'01',
1,
'广州',
trunc(dbms_random.value*1000,6),
trunc(dbms_random.value*1000,6),
trunc(dbms_random.value*1000,2),
trunc(dbms_random.value*1000,2),
trunc(dbms_random.value*1000,0),
trunc(dbms_random.value*1000,0)
from dual;
end loop;
end loop;
commit;
end;
分享到:
相关推荐
Electron From Beginner to Pro Learn to Build Cross Platform Desktop Applications using Github's Electron 英文无水印原版pdf pdf所有页面使用FoxitReader、PDF-XChangeViewer、SumatraPDF和Firefox测试都...
Electron From Beginner to Pro Learn to Build Cross Platform Desktop Applications using Github's Electron 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除
Electron From Beginner to Pro Learn to Build Cross Platform Desktop Applications using Github's Electron 英文无水印原版pdf pdf所有页面使用FoxitReader、PDF-XChangeViewer、SumatraPDF和Firefox测试都...
Learn FileMaker Pro 16.pdf Learn FileMaker Pro 16.pdf Learn FileMaker Pro 16.pdf Learn FileMaker Pro 16.pdf
Pro HTML5 Games Learn to Build your Own Games using HTML5 and JavaScript(2nd) 英文epub 第2版 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
学习50种语言Premium 包含100个课程,为您提供基本词汇。在没有先验知识的情况下,您将学会在现实世界的情况下流利地讲简短的句子。50种语言方法成功地结合了音频和文本,以实现有效的语言学习 ...
Pro Linux System Administration Learn to Build Systems for Your Business Using Free and Open Source Software Pro Linux System Administration Learn to Build Systems for Your Business Using Free and ...
Learn how to make the most of Pro Tools HD 11 Overview Create optimum quality audio using powerful tools of Pro Tools HD Learn how to enhance workflow and creative outputs for recording, editing in ...
Learn HTML5 and JavaScript for Android 英文无水印原版pdf pdf所有页面使用FoxitReader、PDF-XChangeViewer、SumatraPDF和Firefox测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看...
世界上最好的免费应用程序学习英语,其中包含9000多个常用英语单词和短语,具有出色的音频质量。它用于学习和出国旅行的目的 ……课程以科学的方式,尝试和感觉分为类别和子类别。它带来了新的学习方法 ...
使用您的母语免费学习 50种语言! ...在没有先验知识的情况下,您将很快学会在现实世界中流利地说简短的句子。 50语言方法成功地将音频和文本结合起来,可以有效地学习语言。 50种语言对应于通用欧洲框架A1和A2级,...
Learn FileMaker Pro 16 The Comprehensive Guide to Building Custom Databases 英文无水印原版pdf pdf所有页面使用FoxitReader、PDF-XChangeViewer、SumatraPDF和Firefox测试都可以打开 本资源转载自网络,如...
Pro HTML5 Games Learn to Build your Own Games using HTML5 and JavaScript(2nd) 英文无水印pdf 第2版 pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络,如有侵权,请联系上传...
With The IDA Pro Book, you'll learn how to turn that mountain of mnemonics into something you can actually use. Hailed by the creator of IDA Pro as 'profound, comprehensive, and accurate,' the second...
Ethical Hacking With Kali Linux Learn Fast How To Hack Like A Pro.pdf
Pro WPF 4.5 in C# provides a thorough, authoritative guide to how WPF really works. Packed with no-nonsense examples and practical advice you'll learn everything you need to know in order to use WPF ...
Pro Oracle SQL unlocks the power of SQL in the Oracle Database—one of the most potent SQL implementations on the market today. To master it requires a three-pronged approach: learn the language ...
pro JavaFX 8 code 源代码 JavaFX runs on desktops (Mac, Windows, Linux), as well as embedded devices such as the Raspberry Pi. As the Internet of things (IoT) is increasingly realized, JavaFX is well ...