⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 6.7作业.txt

📁 关于oracle和sql的书籍和ppt教程,非常好,本人珍藏品
💻 TXT
字号:
declare
    user_emp scott.emp%rowtype;
    scott.emp_error exception; --自定义异常。
begin 
    create sequence seq_emp increment by 1 start with 1;--建立自增长序列。
    insert into scott.emp (seq_emp.nextval,empno,ename,job,mgr,hiredate,sal,comm,deptno)
           values(1234,'LPY',manager,1234,to_date('1990-09-01','YYYY-MM-DD'),3000,150,10);--插入一条新记录。
    savepoint sp1;--第一部分结束,设置保留点。
    
    alter table scott.emp add age int(6);--给表emp增加一个int型的age字段.
    update scott.emp set age = 30 where deptno=10;
    update scott.emp set age = 41 where deptno=20;
    update scott.emp set age = 20 where deptno=30;
    
    select * into user_emp from scott.emp 
    where deptno = &deptno;
    dbms_output.put_line('年龄'||user_emp.age);
    if age>40 
    then 
       {
        rollback to sp1; --事务回退到sp1保留点。
        commit;          --提交事务。
        }
    else 
       commit;           
    end if;
   exception --捕获异常。
        when scott.emp_error then
        dbms_output.put_line('该表不存在'||scott.emp);
        when user_depton_error then
        dbms_output.put_line('没有这个部门编号'||user_emp.deptno);
end;                   
                   


                        





                   

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -