怎么用,语法等等
刚学到,但是学的有点云里雾里的。
希望哪位牛人能帮忙讲解讲解。
最好能有个什么书籍
我会加分的。希望不知道的不要盖楼。
谢谢

解决方案 »

  1.   

    去下:《Oracle触发器与存储过程高级编程》,这本书写得还是挺好的至于游标给你些例子吧,基本上几种游标类型都有了,不过用到了包:--创建包
    create or replace package emp_info
    is
    --含select的游标
    cursor byempid_cur(
        empid_in in employees.employee_id%type
    )
    is
    select * from employees
    where employee_id=empid_in;
    --完整的游标声明
    cursor bydept_cur(
    department_id_in in employees.department_id%type
    ) return employees%rowtype;
    --不带select语句的游标声明
    type dept_summary_rt is record(
    dept_id employees.department_id %type,
    total_emp_count pls_integer,
    total_salary_count pls_integer
    );
    --自定义记录数据结构
    cursor summary_cur(
    dept_id_in in employees.department_id %type
    ) return dept_summary_rt;
    end emp_info;
    /--创建包体
    create or replace package body emp_info 
    is
    cursor bydept_cur(
        department_id_in in employees.department_id%type--包体变量名称必须和包声明相同,不同会有错

    return employees%rowtype
    is
        select * from employees where department_id=department_id_in;
    cursor summary_cur(
        dept_id_in in employees.department_id%type
    )
    return dept_summary_rt
    is
        select department_id,count(employee_id),sum(salary)
            from employees
            where department_id=dept_id_in;
    end emp_info;
    /--使用包
    declare 
        one_emp emp_info.byempid_cur%rowtype;
    begin
        if emp_info.byempid_cur%isopen then
            null;
        else
            open emp_info.byempid_cur(119);
        end if;
        loop
            fetch emp_info.byempid_cur into one_emp;
            exit when emp_info.byempid_cur%notfound;
            dbms_output.put_line(one_emp.employee_id||
                one_emp.first_name||one_emp.last_name||
                one_emp.salary||one_emp.employee_id);
        end loop;
        close emp_info.byempid_cur;
    end;
    /
      

  2.   

    这东西一箩筐哦..
    XXX从入门到精通
    Oracle Database 9i/10g/11g编程艺术 等等等
    或者官方文档
    楼主是想看开发类的吧,找点基础点的都有介绍...
      

  3.   

    http://blog.csdn.net/szstephenzhou/article/details/7711924
      

  4.   

    Oracle PL/SQL完全自学手册
    这本书不错,适合初学。
      

  5.   

    Oracle Database 9i/10g/11g编程艺术