pl/sql变量和常量

1)复合类型
<1>记录
类似与高级语言中的结构体
declare type emp_record_type is record
(name emp.ename%type,
salary emp.ename%type,
title emp.job%type
);
sp_record emp_record_type;
begin
select ename,sal,job into sp_record from emp 
where empno=7788;
end;
<2>pl/sql表
相当于高级语言中的数组


declare type sp_table_type is table of
--index by binary_integer表示下标是整数
name emp.ename%type index by binary_integer;
sp_table sp_table_type;
begin
select ename into sp_table(0) from emp 
where empno=7788;
end;
2)参照变量
用于存放数组指针的变量。
分为游标变量和对象类型变量


declare
--定义游标
type sp_emp_cursor is ref cursor;
--定义一个游标变量
test_cursor sp_emp_cursor;
--定义变量
v_ename emp.ename%type;
v_sal emp.sal%type;
begin
open test_cursor for select ename,sal from emp where deptno=&no;
loop
   fetch test_cursor into v_ename,v_sal;
   --判定是否test_cursor为空
   exit when test_cursor%notfound;
end loop;
end;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值