Teach Yourself PL/SQL in 21 Days- P7

Teach Yourself PL/SQL in 21 Days- P7: 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 | Collections 27L Analysis Syntax The key here is that the arguments to the constructor are deptl and dept2. Both of those are records of type department ROWTYPE and so match the element type of the table. Obviously it s a bit cumbersome to set things up this way. To add more entries to a table than those you created with the constructor you need to extend the table as discussed in the following section. Extending a Nested Table To extend a nested table so that you can add more entries to it use the extend method. The extend method allows you to add one entry or several entries. It also allows you to clone an existing entry one or more times. The syntax for the extend method is as follows. collection .extend entries_to_add entry_to_clone In this syntax the parameters are as follows collection is the name of the nested table. entries_to_add is a variable or constant indicating the number of new entries you want to add. entry_to_clone is a variable or constant indicating which entry you want to clone. Listing shows the extend method being used and illustrates how constructors work. Input 10 Listing The extend Method Adding Entries to a Nested Table 1 DECLARE 2 --Declare a cursor that returns all department records. 3 CURSOR all_depts IS 4 SELECT 5 FROM department 6 ORDER BY dept_name 7 8 --Define a nested table type. 9 TYPE dept_table IS TABLE OF department ROWTYPE 10 11 --Declare a nested table variable to 12 --hold the employee records that we read in. 13 depts dept_table 14 depts_max PLS_INTEGER 15 inx1 PLS_INTEGER 16 BEGIN 17 --Initialize the index into the table. 18 depts_max 0 19 continues 278 Day 10 Listing continued 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 --Initialize the table by creating one empty entry depts dept_table FOR dept IN all_depts LOOP depts_max depts_max 1 depts depts_max .dept_id depts depts_max .dept_name depts depts_max .no_of_emps END LOOP --Clone

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
Đã 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.