首页 > 学院 > 开发设计 > 正文

pl/SQL编程(四)复合变量composite

2019-11-08 20:44:01
字体:
来源:转载
供稿:网友

复合变量composite,用于存放多个值的变量主要有:

pl/sql记录pl/sql表嵌套表varray

1.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;/
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表