PL/SQL User's Guide and Reference 10g Release phần 7

Tham khảo tài liệu 'pl/sql user's guide and reference 10g release phần 7', 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ả | Defining Object Constructors Calls to methods of an uninitialized object raise the predefined exception NULL_ SELF_DISPATCH. When passed as arguments to IN parameters attributes of an uninitialized object evaluate to NULL. When passed as arguments to OUT or IN OUT parameters they raise an exception if you try to write to them. Accessing Object Attributes You refer to an attribute by name. To access or change the value of an attribute you use dot notation DECLARE r Rational Rational NULL NULL numerator INTEGER denominator INTEGER BEGIN denominator -- Read value of attribute numerator -- Assign value to attribute Attribute names can be chained which lets you access the attributes of a nested object type. For example suppose you define object types Address and Student as follows CREATE TYPE Address AS OBJECT street VARCHAR2 30 city VARCHAR2 20 state CHAR 2 zip_code VARCHAR2 5 CREATE TYPE Student AS OBJECT name VARCHAR2 20 home_address Address phone_number VARCHAR2 10 status VARCHAR2 10 advisor_name VARCHAR2 20 . The Address attribute is an object type that has a zip_code attribute. If s is a Student object you access the value of its zip_code attribute as follows Defining Object Constructors By default you do not need to define a constructor for an object type. The system supplies a default constructor that accepts a parameter corresponding to each attribute. You might also want to define your own constructor To supply default values for some attributes. You can ensure the values are correct instead of relying on the caller to supply every attribute value. To avoid many special-purpose procedures that just initialize different parts of an object. To avoid code changes in applications that call the constructor when new attributes are added to the type. The constructor might need some new code for Using PL SQL Object Types 12-13 Calling Object Constructors example to set the attribute to null but its signature could remain the same so

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
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.