文章分类 -  Oracle

Oracle学习笔记
PLSQL编程,解析字符串的加减乘除
摘要:表:SQL> select b.index_code, b.amount from cin_circ_org_index_amount b; INDEX_CODE AMOUNT-------------------- ----------a64210170 9830.91a64210171 2626.43a64210172 7204.48a64210173 94356.82a64210190 109364.48a64210191 ... 阅读全文
posted @ 2012-07-04 17:02 小波Ooo 阅读(4071) 评论(0) 推荐(0)
cursor 与refcursor及sys_refcursor的区别
摘要:一、显式cursor 显式是相对与隐式cursor而言的,就是有一个明确的声明的cursor。显式游标的声明类似如下(详细的语法参加plsql ref doc ): cursor cursor_name (parameter list) is select ... 游标从declare、open、fetch、close是一个完整的生命旅程。当然了一个这样的游标是可以被多次open进行使用的,显式cursor是静态cursor,她的作用域是全局的,但也必须明白,静态cursor也只有pl/sql代码才可以使用她。下面看一个简单的静态显式cursor的示例: declare c... 阅读全文
posted @ 2012-06-18 13:03 小波Ooo 阅读(226) 评论(0) 推荐(0)
转换函数Pivot 和 Unpivot
摘要:Pivot 和 Unpivot使用简单的 SQL 以电子表格类型的交叉表报表显示任何关系表中的信息,并将交叉表中的所有数据存储到关系表中。下载 Oracle 数据库 11gPivot如您所知,关系表是表格化的,即,它们以列-值对的形式出现。假设一个表名为 CUSTOMERS。SQL> desc customers Name Null? Type ----------------------------------------- -------- --------------------------- CUST_ID... 阅读全文
posted @ 2012-05-31 15:44 小波Ooo 阅读(1203) 评论(0) 推荐(1)
over函数的使用
摘要:1.select e.id, e.depno, e.sal, sum(e.sal) over(partition by depno) as sum from emp e;2.select e.*, sum(e.sal) over(partition by depno order by id)as dept_sum_sal from emp e;3.select e.*, rank() over(order by sal desc nulls last)as dept_sum_s from emp e;4.select e.*, sum(e.sal) ... 阅读全文
posted @ 2012-04-19 13:40 小波Ooo 阅读(203) 评论(0) 推荐(0)
PL/SQL中怎么实现类似其他语言中的数组
摘要:--创建表create table (start_Date date,end_Date date)select * from gd_date_test order by start_date--开始,这段代码是验证时间段是否重叠,重叠则更新end_date为比他大的start_date-1declare type t_emp is table of gd_date_test%rowtype index by binary_integer; v_emp t_emp;begin for i in (select gt.*,rownum from (select * from gd_date_tes 阅读全文
posted @ 2011-09-19 18:45 小波Ooo 阅读(176) 评论(0) 推荐(0)
call_from()
摘要:1.主from按钮的代码declarev_param_list paramlist;beginv_param_list:=get_parameter_list('from_param_list');if not id_null(v_param_list) then destroy_parameter_list(v_param_list); end if; v_param_list := create_parameter_list('form_param_list'); if id_null(v_param_list) then mas_message_pkg.m 阅读全文
posted @ 2011-08-19 15:24 小波Ooo 阅读(313) 评论(0) 推荐(0)
多表连接查询
摘要:select ol.item_id, ii.item_code, ii.description, ol.uom, sum(ol.order_quantity - nvl(ol.delivery_quantity, 0)) as require_quantity, --订单需求 nvl((select sum(a.primary_quantity) from inv_quantities_onhand a where a.storage_location_id in (select x.storage_location_id from inv_storage_locations_vl x whe 阅读全文
posted @ 2011-08-01 18:54 小波Ooo 阅读(285) 评论(0) 推荐(0)
Oracle 中的Userenv()
摘要:1.USEREVN()返回当前用户环境的信息,opt可以是:ENTRYID,SESSIONID,TERMINAL,ISDBA,LABLE,LANGUAGE,CLIENT_INFO,LANG,VSIZE1.ISDBA 查看当前用户是否是DBA如果是则返回trueSQL> select userenv('isdba') from dual;USEREN------FALSE2.SESSION 返回会话标志SQL> select userenv('sessionid') from dual;USERENV('SESSIONID')----- 阅读全文
posted @ 2011-07-29 15:34 小波Ooo 阅读(25746) 评论(0) 推荐(2)