復合變量composite,用于存放多個值的變量主要有:
pl/sql記錄pl/sql表嵌套表varray1.pl/sql記錄
declare--定義一個pl/sql記錄類型emp_record_type 包含兩個數據類型 spName,salarytype emp_record_type is record(spName emp.name%type,salary emp.sal%type);--定義一個sp_record變量,這個變量的類型是emp_record_typesp_record emp_record_type;beginselect name,sal into sp_record from emp where id=&no;dbms_output.put_line('姓名是:'||sp_record.spName||'工資是:'||sp_record.salary);end;/pl/sql表實例 相當于高級語言中的數組 但高級語言數組下標不能為負數,而pl/sql下標可以為負數
declareindex by binary_integer 下標是整數--定義一個pl/sql表實例emp_table_type type emp_table_type is table of emp.name%type index by binary_integer;--定義了sp_table 類型是emp_table_typesp_table emp_table_type;beginselect name into sp_table(0) from emp where id=&no; &no定義的變量dbms_output.put_line('姓名是:'||sp_table(0));end;/新聞熱點
疑難解答