Q:

Write a block in PL/SQL to shows how are records are declared and initialized

0

Write a block in PL/SQL to shows how are records are declared and initialized.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

DECLARE
    TYPE address_detls IS RECORD (
      street_number NUMBER(4),
      street_name VARCHAR2(25),
      country_name VARCHAR2(15) );
    TYPE person_delts IS RECORD (
      emp_id employees.employee_id%TYPE,
      emp_first_name employees.first_name%TYPE,
      emp_last_name employees.last_name%TYPE,
      emp_address ADDRESS_DETLS );
    person_info PERSON_DELTS;
BEGIN
    person_info.emp_id := 501;
    person_info.emp_first_name := 'Allan';
    person_info.emp_last_name := 'Doran';
    person_info.emp_address.street_number := 601;
    person_info.emp_address.street_name := 'Riverside Drive Redding';
    person_info.emp_address.country_name := 'USA';
dbms_output.Put_line('--------------------------------------------------------------');
dbms_output.Put_line('Personal Details::');
dbms_output.Put_line('--------------------------------------------------------------');
dbms_output.Put_line('Name: '
                     || person_info.emp_last_name
                     || ', '
                     || person_info.emp_first_name);
dbms_output.Put_line('Address: '
                     || To_char(person_info.emp_address.street_number)
                     || ' '
                     || person_info.emp_address.street_name
                     ||', '
                     || person_info.emp_address.country_name);
END;
/
 Sample Output:
SQL> /
--------------------------------------------
Personal Details::
--------------------------------------------
Name: Doran, Allan
Address: 601 Riverside Drive Redding, USA

PL/SQL procedure successfully completed.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now