PL/SQL--复杂数据类型
2016-12-28 16:56
465 查看
PL/SQL–复杂数据类型
PLSQL 中常用的自定义类型就两种:记录类型、PLSQL 内存表类型(根据表中的数据字段的简单和复杂) 程度又可分别实现类似于简单数组和记录数组的功能记录类型
declare type emp_type is record (last_name varchar2(10), first_name varchar2(10), salary number(6) not null default 0); emp_param emp_type; begin select first_name, last_name, salary into emp_param.first_name, emp_param.last_name, emp_param.salary from employees where employee_id = 100; dbms_output.put_line(emp_param.first_name); end;
行类型
declare emp_param employees%rowtype; begin select * into emp_param from employees where employee_id = 100; dbms_output.put_line(emp_param.email); end;
内存表
PLSQL 内存表即 Index By Table , 这种结构类似于数组,使用主键提供类似于数组那样的元素访问。 这种类型必须包括两部分:1 、使用 BINARY_INTEGER 类型构成的索引主键; 2 、另外一个简单类型或者用户自定义类型的字段作为具体的数组元素。
declare type index_type is table of employees.last_name%type index by binary_integer; index_param index_type; begin for i in 100..106 loop select last_name into index_param(i) from employees where employee_id = i; end loop; for j in 100..index_param.count+99 loop dbms_output.put_line(index_param(j)); end loop; end;
相关文章推荐
- PL/SQL 基础---复杂数据类型和自定义类型
- ODP.NET与复杂的PL/SQL数据类型(Using ODP.NET To Deal With Complex PLSQL Data Types)
- ORACLE HANDBOOK系列之六:ODP.NET与复杂的PL/SQL数据类型(Using ODP.NET To Deal With Complex PLSQL Data Types)
- pl/sql入门第二章--复合数据类型
- 《PL/SQL 语言开发参考手册》之三:变量与数据类型
- PL/SQL数据类型及操作符
- PL/SQL学习笔记-变量作用域及数据类型深入
- 第三章 PL/SQL数据类型
- oracle PL/SQL的基本构成,块结构和基本语法要求,数据类型,变量定义,运算符和函数
- PL/SQL复合数据类型—record,集合(索引表,嵌套表,VARRAY)—之四
- 第三章 PL/SQL数据类型
- PL/SQL的基本数据类型!!!
- PL/SQL(二)数据类型
- PL/SQL的数据类型和常用函数
- 解决从pl/sql查看oracle的number(19)类型数据为科学计数法的问题
- PL/SQL编程复合数据类型之PL/SQL记录
- PL/SQL数据类型及常用函数
- PL/SQL学习笔记-常量变量及数据类型初步
- PL/SQL数据类型及操作符
- PL/SQL中的数据类型隐式转换规则