Teach Yourself PL/SQL in 21 Days- P8

Teach Yourself PL/SQL in 21 Days- P8: Welcome to Sams Teach Yourself PL/SQL in 21 Days, Second Edition. The fact that you purchased this book indicates that you have an interest in learning the PL/SQL language, which is Oracle’s relational database procedural programming language. It allows you to develop powerful and complex programs to access and manipulate data in the Oracle8i database. We have attempted to include as many examples of PL/SQL code as possible to illustrate PL/SQL features | Writing Database Triggers 327 49 Employees are limited to a max of two 50 END IF 51 END LOOP 52 END 53 54 Trigger created. Analysis Notice in line 1 that the previous trigger is dropped. Be sure to do this. The table-level before trigger in lines 3-9 is fired at the beginning of an INSERT or UPDATE statement. It calls a package procedure that initializes the list counter. The rowlevel trigger named only_two_departments_2 defined in lines 11-19 is fired for each row added or changed. This trigger adds the primary key of each record to the list maintained in the package-level PL SQL table. The third trigger defined in lines 21-52 is the one that does the actual validation work. It is fired after the INSERT or UPDATE statement is complete. It loops through each new or changed record and checks to be sure that each employee in question has a maximum of two department assignments. Now that you have created these triggers and the emp_dept_procs package you can execute the SQL statements shown in Listing in order to demonstrate that it works. 11 Input Output Listing Testing the Triggers and Package That Enforce the Two-Department Rule 1 INSERT INTO employee 2 emp_id emp_name VALUES 403 Freddie Fisher1 3 1 row created. 4 INSERT INTO employee 5 emp_id emp_name VALUES 404 Charlie Tuna 6 1 row created. 7 INSERT INTO department 8 dept_id dept_name VALUES 404 Scale Processing 9 1 row created. 10 INSERT INTO department 11 dept_id dept_name VALUES 405 Gutting 12 1 row created. 13 INSERT INTO department 14 dept_id dept_name VALUES 406 Unloading 15 1 row created. 16 INSERT INTO emp_dept 17 emp_id dept_id VALUES 403 404 18 1 row created. 19 INSERT INTO emp_dept 20 emp_id dept_id VALUES 403 405 21 1 row created. 22 INSERT INTO emp_dept continues 328 Day 11 Listing continued 23 emp_id dept_id VALUES 404 405 24 1 row created. 25 26 27 INSERT INTO emp_dept emp_id dept_id VALUES 404 406 1 row created. 28 29 30 INSERT INTO emp_dept emp_id dept_id VALUES 403

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
112    100    3    29-06-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.