Oracle中如图怎么写存储过程

过期的豆豆糖 2012-02-27 11:25:21

有这样一个业务怎么写存储过程
...全文
86 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
过期的豆豆糖 2012-02-27
  • 打赏
  • 举报
回复
麻烦把脚本单独拿出来运行一下看,本来是张图片,可不知道怎么加上去,是一个多个条件的高级查询,我这么写的,可是当我给输入条件为空时,他什么也查不出来

-----------------------8.商品销售表存储过程
--按照日期,销售单号模糊查询,汇总表或明细表,按日期顺序,按客户分组
--查询 :销售日期 单号,客户名称,销售单价,销售数量,销售总额,商品备注
--客户编号,商品编号,商品名称,单位,规格型号,业务员
create or replace procedure proc_commoditysellInfo_find
(
info_cursor out sys_refcursor,
startdate in varchar2,
stopdate in varchar2,
datesort in varchar2 default null,--日期排序
clientgroup in varchar2 default null,--客户分组
condition in varchar2 default null,--销售单号
--
commodityname in varchar2 default null,--商品名称
commoditymodel in varchar2 default null,--商品规格
employeename in varchar2 default null,--业务员
customerName in varchar2 default null,--客户名称
customerType in varchar2 default null,--客户类型
customerLevel in varchar2 default null,--客户阶段
customerRank in varchar2 default null,--客户级别
customerSource in varchar2 default null,--客户来源
IndustryType in varchar2 default null,--行业类别
province in varchar2 default null,--省份
city in varchar2 default null--城市
)
as
protype_sql varchar2(2000);--查询所有的sql语句
condition_sql1 varchar2(500);--条件1,起始日期,到终止日期
condition_sql2 varchar2(500);--条件2,销售单号
condition_sql3 varchar2(500);--条件3,是否按日期排序
condition_sql4 varchar2(500);--条件4,是否按客户分组
condition_sql5 varchar2(500);--条件5,商品名称
condition_sql6 varchar2(500);--条件6,商品规格
condition_sql7 varchar2(500);--条件7,业务员
condition_sql8 varchar2(500);--条件8,客户名称
condition_sql9 varchar2(500);--条件9,客户类型
condition_sql10 varchar2(500);--条件10,客户阶段
condition_sql11 varchar2(500);--条件11,客户级别
condition_sql12 varchar2(500);--条件12,客户来源
condition_sql13 varchar2(500);--条件13,行业类别
condition_sql14 varchar2(500);--条件14,省份
condition_sql15 varchar2(500);--条件15,城市

all_sql varchar2(2000);--最终sql语句
begin
protype_sql := 'select csi.selldate,csi.id,ci.id,ci.customername,c.id,c.commodityname,c.commodityunit,c.commoditymodel,
cs.commPrice,cs.commSellNum,cs.totalMoney,e.employeename,c.remark,ci.customerType,ci.customerLevel,ci.customerpank,
ci.customerSource,ci.IndustryType,ci.province,ci.city,csi.amountReceivable,csi.PaidUpMoney,csi.preferentialPrice
from commoditysellInfo csi,CustomerInformation ci,commodity c,commoditysell cs,employeeinfo e
where csi.cid = ci.id and cs.commodityId= c.id and e.id = csi.empid and cs.salesSlip = csi.id';
condition_sql1:=' and csi.selldate between to_date('''||startdate||''',''yyyy-mm-dd'') and to_date('''||stopdate||''',''yyyy-mm-dd'')';
condition_sql2:=' and csi.id like ''%' ||condition|| '%''';
condition_sql3:=' order by csi.selldate desc';

--
condition_sql5:=' and c.commodityname='''||commodityname||'''';
condition_sql6:=' and c.commoditymodel='''||commoditymodel||'''';
condition_sql7:=' and e.employeename='''||employeename||'''';
condition_sql8:=' and ci.customername='''||customerName||'''';
condition_sql9:=' and ci.customerType='''||customerType||'''';
condition_sql10:=' and ci.customerLevel='''||customerLevel||'''';
condition_sql11:=' and ci.customerRank='''||customerRank||'''';
condition_sql12:=' and ci.customerSource='''||customerSource||'''';
condition_sql13:=' and ci.IndustryType='''||IndustryType||'''';
condition_sql14:=' and ci.province='''||province||'''';
condition_sql15:=' and ci.city='''||city||'''';
all_sql:=protype_sql;
if startdate is not null then
all_sql:=protype_sql||condition_sql1;
end if;
if stopdate is not null then
all_sql:=protype_sql||condition_sql1;
end if;
if datesort is not null then
all_sql:=protype_sql;
end if;
if condition is not null then
all_sql:= all_sql||condition_sql2;
end if;

if commodityname is not null then
all_sql:=all_sql||condition_sql5;
end if;
if commoditymodel is not null then
all_sql:=all_sql||condition_sql6;
end if;
if employeename is not null then
all_sql:=all_sql||condition_sql7;
end if;
if customerName is not null then
all_sql:=all_sql||condition_sql8;
end if;
if customerType is not null then
all_sql:=all_sql||condition_sql9;
end if;
if customerLevel is not null then
all_sql:=all_sql||condition_sql10;
end if;
if customerRank is not null then
all_sql:=all_sql||condition_sql11;
end if;
if customerSource is not null then
all_sql:=all_sql||condition_sql12;
end if;
if IndustryType is not null then
all_sql:=all_sql||condition_sql13;
end if;
if province is not null then
all_sql:=all_sql||condition_sql14;
end if;
if city is not null then
all_sql:=all_sql||condition_sql15;
end if;

open info_cursor for all_sql||condition_sql1;
end;
过期的豆豆糖 2012-02-27
  • 打赏
  • 举报
回复
<form action="stcommoditysellinfo_findAll" method="post">
<table width="200" border="1">
<tr>
<td nowrap="nowrap">
分析日期:
</td>
<td nowrap="nowrap">
<input type="text" name="startDate" readOnly onClick=setDay(this);
value="2000-01-01">
</td>
<td nowrap="nowrap">

</td>
<td nowrap="nowrap">
<input type="text" name="stopDate" readOnly
onClick=setDay(this); value="2012-01-01">
</td>
</tr>
<tr>
<td nowrap="nowrap">
商品名称:
</td>
<td colspan="3" nowrap="nowrap">
<select id="select3" name="commodityname">
<c:forEach items="${list}" var="lv">
<option value="${lv[5]}">
${lv[5]}
</option>
</c:forEach>
</select>
</td>
</tr>
<tr>
<td nowrap="nowrap">
商品规格:
</td>
<td nowrap="nowrap">
<select name="commoditymodel" id="select4">

</select>
</td>
<td nowrap="nowrap">
业务员:
</td>
<td nowrap="nowrap">
<select name="employeename" id="select4">

</select>
</td>
</tr>
<tr>
<td nowrap="nowrap">
客户名称:
</td>
<td colspan="3" nowrap="nowrap">
<select name="customerName" id="select5">

</select>
</td>
</tr>
<tr>
<td nowrap="nowrap">
客户类型:
</td>
<td nowrap="nowrap">
<select name="customerType" id="select6">

</select>
</td>
<td nowrap="nowrap">
客户阶段:
</td>
<td nowrap="nowrap">
<select name="customerLevel" id="select6">
</select>
</td>
</tr>
<tr>
<td nowrap="nowrap">
客户级别:
</td>
<td nowrap="nowrap">
<select name="customerRank" id="select7">

</select>
</td>
<td nowrap="nowrap">
客户来源:
</td>
<td nowrap="nowrap">
<select name="customerSource" id="select7">

</select>
</td>
</tr>
<tr>
<td nowrap="nowrap">
行业类别:
</td>
<td colspan="3" nowrap="nowrap">
<select name="IndustryType" id="select8">

</select>
</td>
</tr>
<tr>
<td nowrap="nowrap">
省份/地区:
</td>
<td nowrap="nowrap">
<select name="province" id="select9">

</select>
</td>
<td nowrap="nowrap">
城市:
</td>
<td nowrap="nowrap">
<select name="city" id="select9">

</select>
</td>
</tr>
<tr>
<td colspan="2" nowrap="nowrap">
<label>
<input type="submit" name="button" id="button" value="确定" />
</label>
</td>
<td colspan="2" nowrap="nowrap">
<input type="reset" name="button2" id="button2" value="取消" />
</td>
</tr>
</table>
</form>
勿勿 2012-02-27
  • 打赏
  • 举报
回复
图片没了
第一篇 Oracle管理配置 第1章 Oracle安装配置(教学视频:10分钟) 23 1.1 Oracle简介 23 1.1.1 数据库术语 23 1.1.2 主流数据库简介 24 1.1.3 Oracle数据库的特点 24 1.2 安装Oracle数据库 25 1.2.1 Oracle数据库的版本变迁及安装环境 25 1.2.2 安装过程 26 1.2.3 安装中需要注意的问题 27 1.3 本章小结 28 1.4 习题 28 第2章 Oracle常用工具(教学视频:7分钟) 29 2.1 Net Configuration Assistant(网络配置助手) 29 2.1.1 监听程序配置 29 2.1.2 命名方法配置 31 2.1.3 本地Net服务名配置 32 2.2 Net Manager(网络管理员) 34 2.3 本章实例 36 2.4 本章小结 38 2.5 习题 38 第3章 SQL Plus和PL/SQL(教学视频:11分钟) 39 3.1 SQL Plus与PL/SQL简介 39 3.2 使用SQL Plus 40 3.2.1 登录SQL Plus 40 3.2.2 SQL Plus输出结果的格式化 41 3.2.3 SQL Plus小结 46 3.3 PL/SQL 46 3.3.1 PL/SQL常用开发工具 46 3.3.2 开发一个简单的PL/SQL程序 48 3.4 本章实例 49 3.5 本章小结 50 3.6 习题 50 第二篇 Oracle数据库对象 第4章 Oralce数据库(教学视频:15分钟) 51 4.1 创建Oracle数据库 51 4.2 Oracle数据库的相关术语 52 4.2.1 数据库 53 4.2.2 数据库实例和SID 53 4.2.3 ORACLE_SID 54 4.3 Oracle数据库的备份与恢复 55 4.3.1 逻辑备份/恢复(导出/导入) 55 4.3.2 物理备份/恢复 56 4.3.3 利用PL/SQL Developer备份数据库 60 4.4 本章实例 61 4.5 本章小结 61 4.6 习题 62 第5章 Oracle数据表对象(教学视频:42分钟) 63 5.1 Oracle表空间 63 5.1.1 Oracle表空间简介 63 5.1.2 创建Oracle表空间 64 5.1.3 查看表空间 66 5.1.4 修改数据库默认表空间 67 5.1.5 修改表空间名称 68 5.1.6 删除表空间 69 5.2 创建Oracle数据表 70 5.2.1 利用工具创建数据表 70 5.2.2 利用工具查看数据表 71 5.2.3 利用命令创建数据表 72 5.2.4 利用命令查看表结构 72 5.3 修改Oracle数据表结构 73 5.3.1 利用工具修改数据表结构 73 5.3.2 利用命令修改数据表结构 74 5.4 删除数据表 75 5.4.1 利用工具删除数据表 76 5.4.2 利用SQL语句删除数据表 76 5.5 备份/恢复数据表 76 5.5.1 利用工具备份/恢复数据表 77 5.5.2 利用命令备份/恢复数据表 82 5.6 临时表 83 5.6.1 临时表简介 83 5.6.2 会话级临时表 84 5.6.3 事务级临时表 85 5.6.4 查看临时表在数据库中的信息 86 5.6.5 临时表的应用场景 86 5.7 特殊的表dual 87 5.7.1 分析dual表 87 5.7.2 dual表的应用场景 87 5.7.3 修改dual表对查询结果的影响 88 5.8 本章实例 89 5.9 本章小结 90 5.10 习题 90 第6章 约束(教学视频:43分钟) 91 6.1 主键约束 91 6.1.1 主键简介 91 6.1.2 创建主键约束 92 6.1.3 修改表的主键约束 94 6.1.4 主键应用场景 96 6.2 外键约束 97 6.2.1 外键简介 97 6.2.2 创建外键约束 97 6.2.3 级联更新与级联删除 100 6.2.4 修改外键属性 102 6.2.5 外键使用 104 6.3 唯一性约束 105 6.3.1 唯一性约束简介 105 6.3.2 创建唯一性约束 105 6.3.3 修改唯一性约束 107 6.3.4 唯一性约束的使用 108 6.4 检查约束 108 6.4.1 检查约束简介 108 6.4.2 创建检查约束 108 6.4.3 修改检查约束 110 6.4.4 检查约束的使用 111 6.5 默认值约束 111 6.5.1 默认值约束简介 112 6.5.2 创建默认值约束 112 6.5.3 修改默认值约束 113 6.6 本章实例 115 6.7 本章小结 116 6.8 习题 116 第7章 视图(教学视频:50分钟) 117 7.1 关系视图 117 7.1.1 建立关系视图 117 7.1.2 修改/删除视图 118 7.1.3 联接视图 120 7.1.4 编译视图 122 7.1.5 使用force选项强制创建视图 124 7.1.6 利用视图更新数据表 125 7.1.7 with check option选项 126 7.1.8 关系视图小结 128 7.2 内嵌视图 128 7.2.1 内嵌视图简介 128 7.2.2 内嵌视图的使用 128 7.2.3 内嵌视图小结 130 7.3 对象视图 131 7.3.1 对象视图简介 131 7.3.2 对象视图简介 131 7.4 物化视图 133 7.4.1 物化视图简介 133 7.4.2 物化视图的使用 133 7.4.3 物化视图的数据加载 135 7.4.4 物化视图的数据更新 135 7.4.5 查询重 136 7.5 本章小结 136 7.6 本章实例 137 7.7 习题 137 第8章 函数与存储过程(教学视频:48分钟) 138 8.1 函数 138 8.1.1 函数简介 138 8.1.2 创建函数 139 8.1.3 函数中的括号 140 8.1.4 函数的参数 141 8.1.5 函数的确定性 142 8.1.6 典型函数举例 143 8.2 存储过程 144 8.2.1 存储过程简介 144 8.2.2 创建存储过程 144 8.2.3 存储过程的参数——IN参数 146 8.2.4 存储过程的参数——OUT参数 147 8.2.5 存储过程的参数——IN OUT参数 149 8.2.6 存储过程的参数——参数顺序 149 8.2.7 存储过程的参数——参数的默认值 152 8.2.8 存储过程的参数——参数顺序总结 153 8.3 程序包 153 8.3.1 规范 153 8.3.2 主体 155 8.3.3 调用程序包中的函数/存储过程 157 8.3.4 程序包中的变量 158 8.4 本章实例 159 8.5 本章小结 161 8.6 习题 161 …… 第9章 游标(教学视频:36分钟) 162 第10章 触发器(教学视频:58分钟) 178 第11章 序列(教学视频:28分钟) 206 第12章 用户角色与权限控制(教学视频:45分钟) 215 第三篇 Oracle中的SQL 第13章 Oracle数据类型(教学视频:21分钟) 231 第14章 Oracle中的函数与表达式(教学视频:111分钟) 240 第15章 Oracle中的控制语句(教学视频:16分钟) 282 第16章 SQL查询(教学视频:55分钟) 290 第17章 SQL更新数据(教学视频:34分钟) 319 第四篇 Oracle编程高级应用 第18章 数据库速度优化与数据完整性(教学视频:32分钟) 332 第19章 数据一致性与事务管理(教学视频:46分钟) 341 第20章 并发控制(教学视频:35分钟) 356 第21章 Oracle中的正则表达式(教学视频:29分钟) 369 第五篇 Oracle与编程语言综合使用实例 第22章 Oracle在Java开发中的应用(教学视频:38分钟) 376 第23章 Oracle在C#开发中的应用(教学视频:12分钟) 391

17,090

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧