易截截图软件、单文件、免安装、纯绿色、仅160KB

Oracle学习笔记(十三)

用游标编程实现
1.对所有员工,如果该员工职位是MANAGER,并且在DALLAS工作那么就给他薪金加15%;
如果该员工职位是CLERK,并且在NEW YORK工作那么就给他薪金扣除5%;其他情况不作处理
declare
  cursor c1 is select * from emp;
  c1rec c1%rowtype;
  v_loc varchar2(20);
begin
  for c1rec in c1 loop
    select loc into v_loc from dept where deptno = c1rec.deptno;
    if c1rec.job = 'MANAGER' and v_loc = 'DALLAS' then
       update emp set sal = sal * 1.15 where empno  = c1rec.empno;
    elsif c1rec.job='CLERK' and v_loc = 'NEW YORK' then
       update emp set sal = sal * 0.95 where empno  = c1rec.empno;
    else
  null;
 
   end if;
    
  end loop;  
end; 
2.对直接上级是'BLAKE'的所有员工,按照参加工作的时间加薪:
    81年6月以前的加薪10%
    81年6月以后的加薪5%
declare
  cursor c1 is select * from emp where mgr = (select
      empno from emp where ename='BLAKE'); --直接上级是'BLAKE'的所有员工
  c1rec c1%rowtype;
begin
  for c1rec in c1 loop
    if c1rec.hiredate < '01-6月-81' then
       update emp set sal = sal * 1.1 where empno = c1rec.empno;
    else
       update emp set sal = sal * 1.05 where empno = c1rec.empno;    
    end if;
  end loop;
end;
3.根据员工在各自部门中的工资高低排出在部门中的名次(允许并列).
<1>  一条SQL语句
   select deptno,ename,sal,(select count(*) + 1
from emp where deptno = a.deptno
and sal > a.sal) as ord
from emp a
order by deptno,sal desc;
<2> PL/SQL块
declare 
  cursor cc is
    select * from dept;
  ccrec cc%rowtype;
  curs


相关文档:

ORACLE sql语句笔记

windows上存在32bit的限制,如AIX、HP UNIX 等有明确的64BIT OS and ORACLE的版本,32bit oracle可以装在64bit os 上,64 bit oracle不能装在32 bit OS上
oracle是64bit or 32 bit,32bit 通常 SGA有 1.7G 的限制(某些OS的处理或者WINDOWS上有特定设定可以支持到2G以上甚至达到3.7G
如何查出前台正在发出的sql语句:
sele ......

Oracle中用一句SQL语句实现行列转换

SQL*PLus>   desc   emp;  
    名称                                                                   &nbs ......

mysql 与Oracle 函数对比

Oracle函数和mysql函数比较
1.       Oracle中的to_number()转换成数字;
Oracle> Select to_number(‘123’) from dual;  -----         123;
           &nbs ......

mysql,sqlserver,oracle三种数据库的大对象存取

mysql 大对象存取:
  类型一般应该用mediumblod,
  blob只能存2的16次方个byte,
  mediumblod是24次方,
  一般来说够用了.longblob是32次方有些大.
  MYSQL默认配置只能存1M大小的文件,要修改配置,WIN版本的在mysql.ini文件中
  修改max_allowed_packet,net_buffer_length等几个参数,或直接SET GLOBAL va ......

oracle与sqlserver执行count(*)返回的结果兼容

由于以前都是在sqlserver 2005处理,现在客户要求oracle数据库服务器,
最初的代码为:
allRecordSize = (Integer) rs1.getObject(1);    //Integer allRecordSize=0;
当执行的时候报:BigDecimal无法转化为Integer类型
为了兼容两者修改后的代码为:
  Object o = rs1.getObject(1);
 &nbs ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号