ITPub博客

首页 > 数据库 > Oracle > PL/SQL中的复合变量

PL/SQL中的复合变量

原创 Oracle 作者:xlqman 时间:2010-07-29 16:42:05 0 删除 编辑

PL/SQL中的数组就是TABLE变量类型:

声明方法:

declare

type type_table_emp_empno is table of emp.empno%type index by binary_integer;

v_empnos type_table_emp_empno;

begin

v_empnos(0) := 1234;

v_empnos(1) :=

;

v_empnos(-1) := 4321;

dbms_output.pub_line(v_empnos(-1));

;

PL/SQL中的Record变量相当于JAVA中的类

declare

type type_record_dept is record

(

Deptno dept.deptno%type,

Dname dept.dname%type,

Loc dept.loc%type

);

v_temp type_record_dept;

begin

v_temp.deptno := 50;

v_temp.dname :=’asdf’;

v_temp.loc := ‘bj’;

也可以根据表的行类型定义record变量,即使用%rowtype

Declare

V_temp dept%rowtype;

Begin

V_temp.deptno := 50;

[@more@]

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/21548840/viewspace-1035626/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2009-08-22

  • 博文量
    22
  • 访问量
    273277