存储过程:
- set serveroutput on;
- create or replace procedure PrintStudentInfo is
- begin
- for s_current in (select * from student) loop
- dbms_output.put(s_current.sno || '\');
- dbms_output.put(s_current.sname || '\');
- dbms_output.put_line(s_current.age);
- end loop;
- end PrintStudentInfo;
- /
- exec PrintStudentInfo;
- create or replace procedure GetStudentInfo(ID in varchar2) is
- type StudentInfo is record(
- sID student.sno%type,
- sName student.sname%type,
- className course.Cname%type
- );
- v_studentInfo StudentInfo ;
- begin
- select s.sno,s.sname,c.cname
- into v_studentInfo
- from student s join course c
- on s.sclass=c.sid
- where s.sno=ID;
- dbms_output.put(v_studentInfo.SID || '\');
- dbms_output.put(v_studentInfo.Sname || '\');
- dbms_output.put(v_studentInfo.className || '\');
- exception when no_data_found then
- dbms_output.put_line('not found this student');
- end GetStudentInfo;
- /
- declare
- studentID varchar2(20):='804';
- begin GetStudentInfo(id=>studentID);
- end;
- /
- drop table student_log;
- create table student_log(
- who varchar2(30),
- ActionType varchar2(10),
- ModelDate timestamp
- );
- --触发
- create or replace trigger InsertLog_trigger
- after insert on student
- begin
- insert into student_log values(user,'INSERT',sysdate);
- end;
- /
- insert into student(sno,age,sname) values(222190912,23,'李小龙');
- select * from student_log;
- alter table student_log add Student_ID varchar2(10);
- alter trigger insertlog_trigger disable;
- create or replace trigger insert_row_log_trigger
- before insert on student
- referencing new as new_value
- for each row
- begin
- insert into student_log
- values(user,'INsert',sysdate,:new_value.SNO) ;
- end;
- /
- insert into student(sno,age,sname) values(32565132,231,'成长伦');
- select * from student_log;
- --test
- -- exp system/manager@ORCL file=d:\daochu.dmp log=d:\logs\log.log full=y
- imp system/sa@ORCL full=y file=d:\daochu.dmp log=d:\logs\log.log ignore=y
更多Oracle相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12
