TAILIEUCHUNG - Oracle PL/SQL by Example- P4

Tham khảo tài liệu 'oracle pl/sql by example- p4', công nghệ thông tin, cơ sở dữ liệu phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | LAB Lab Exercises 122 modified_by VALUES v_course v_sec_num v_instructor_id SYSDATE USER SYSDATE USER -- if number of sections added is ten exit the loop EXIT WHEN v_sec_num 10 END LOOP -- control resumes here COMMIT END To add ten sections for the given course number the test value of v_sec_num in the EXIT condition is changed to 10. Note that before you execute this version of the script you need to delete records from the SECTION table that were added when you executed the original example. If you did not run the original script you do not need to delete records from the SECTION table. The SECTION table has a unique constraint defined on the COURSE_NO and SECTION_NO columns. In other words the combination of course and section numbers allows you to uniquely identify each row of the the original script is executed it creates four records in the SECTION table for course number 430 section numbers 1 2 3 and 4. When the new version of this script is executed the unique constraint defined on the SECTION table is violated because there already are records corresponding to course number 430 and section numbers 1 2 3 and 4. Therefore these rows must be deleted from the SECTION table as follows DELETE FROM section WHERE course_no 430 AND section_no 4 COMMIT As soon as these records are deleted from the SECTION table you can execute the new version of the script. D How would you change the script to add only even-numbered sections the maximum section number is 10 for the specified course number ANSWER The script should look similar to the following are shown in run this script you need to delete records from the SECTION table that were added by the previous each iteration of the loop the value of v_sec_num should be incremented by two as shown -- version SET SERVEROUTPUT ON DECLARE v_course type 43 0 v_instructor_id type 102 v_sec_num .

TỪ KHÓA LIÊN QUAN
Đã 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.