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

oracle 笔记 VI 之游标 (CURSOR)

 游标(CURSOR),很重要
游标:用于处理多行记录的事务
游标是一个指向上下文的句柄(handle)或指针,简单说,游标就是一个指针
1 处理显式游标
  显式游标处理需 4个 PL/SQL 步骤,显示游标主要用于处理查询语句
  (1) 定义游标
  格式:  CURSOR cursor_name [(partment[,parameter]...)] IS select_statement;
   定义的游标不能有 INTO 子句
  (2) 打开游标
   OPEN cursor_name[...];
  PL/SQL 程序不能用 OPEN 语句重复打开一个游标
  (3)提取游标数据
   FETCH cursor_name INTO {variable_list | record_variable};
  (4) 关闭游标
   CLOSE cursor_name;
  例 1 查询前 10 名员工的信息  
   declare
    --定义游标
    cursor c_cursor is select last_name,salary  from employees where rownum < 11 order by salary;
    v_name employees.last_name%type;
    V_sal employees.salary%type;
 
    begin
      --打开游标
      open c_cursor;
      -- 提取游标数据
      fetch c_cursor into v_name,v_sal;
       while c_cursor %found loop
             dbms_output.put_line(v_name || ':' || v_sal);
             fetch c_cursor into v_name,v_sal;
        end loop;
  
       --关闭游标
       close c_cursor;
   end;
----------------------------------
 练习: 输入部门号 dep_id,查询该部门的平均工资 : avg_sal,员工工资为 salary
       若 salary < avg_sal - 500 工资涨 500
       若 avg_sal - 500 <= salary < avg_sal + 500 工资涨 300
       若


相关文档:

Oracle字符集修改问题

 经常有同事咨询oracle数据库字符集相关的问题,如在不同数据库做数据迁移、同其它系统交换数据等,常常因为字符集不同而导致迁移失败或数据库内数据变成乱码。现在我将oracle字符集相关的一些知识做个简单总结,希望对大家今后的工作有所帮助。
  一、什么是oracle字符集
  Oracle字符集是一个字节数据的解释 ......

oracle 笔记 III 之存储过程与函数

DML(Manipulation):数据操作语言
CRUD
DDL(Definition): 数据定义语言,与表,索引,同义词有关
create,alter,drop,rename,truncate(清空)
DCL(Control): 数据控制语言,与权限有关
grant,revoke
TCL(Transaction Control): 事务控制语言,与事务有关
commit,rollback,savepoint
==========================
存储 ......

ORACLE 11G DBA course given in English.

This course is aim to train the great DBA with good English speaking.
In recent years, more demands of Oracle DBA, but most of Senior DBAs are required to speak good English.
English has become the great barrier for more peoples in their career development, you must have the deep feeling about it ......

Oracle恢復意外刪除的數據

 1. flashback table table_test to timestamp to_timestamp('20091103000000','yyyymmddhh24miss');
 2.如果報錯ORA-08189: cannot flashback the table because row movement is not enabled
 3.alter table table_test enable row movement;
 4.OK ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号