Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
BACKEND CONCEPTS Lecture No. 10 Thursday, September 21, 2000 “Backend programming” CIS 560: Database System Concepts Kansas State University Department of Computing and Information Sciences BACKEND CONCEPTS CONTENTS • Stored procedures • Functions • Triggers • Reports • Assignment 3 CIS 560: Database System Concepts Kansas State University Department of Computing and Information Sciences BACKEND CONCEPTS Stored procedure create or replace procedure SAMPLE_PROC (ssn_val IN number, sal_val IN number) AS BEGIN insert into salary values (ssn_val, sal_val); END; show errors; CIS 560: Database System Concepts Kansas State University Department of Computing and Information Sciences BACKEND CONCEPTS Functions create function SAMPLE_FUNC (ssn_val IN number) RETURN NUMBER IS sal_val NUMBER; BEGIN select salary INTO sal_val from SALARY where ssn = ssn_val; RETURN (sal_val); EXCEPTION WHEN NO_DATA_FOUND THEN RAISE_APPLICATION_ERROR (-20100, ’ERROR'); END; CIS 560: Database System Concepts Kansas State University Department of Computing and Information Sciences BACKEND CONCEPTS Triggers • Row level triggers • Statement level triggers • Before and after triggers • Instead of triggers CIS 560: Database System Concepts Kansas State University Department of Computing and Information Sciences BACKEND CONCEPTS Triggers • create trigger SAMPLE_TRIG before update on SALARY for each row when (new.salary < old.salary) begin insert into SALARY_LOWERED values (old.ssn); end; • alter trigger sample_trig enable; • alter table salary enable all triggers; CIS 560: Database System Concepts Kansas State University Department of Computing and Information Sciences BACKEND CONCEPTS Reports rem Printing a report ttitle 'Salary values' btitle 'Report generated by Arul' column ssn heading 'Social|Security|number' rem column ssn format a12 column ssn truncated column salary heading 'salary' rem column salary format a20 set linesize 40 set pagesize 20 spool report.lst select * from salary; spool off CIS 560: Database System Concepts Kansas State University Department of Computing and Information Sciences BACKEND CONCEPTS Assignment 3... CIS 560: Database System Concepts Kansas State University Department of Computing and Information Sciences