oracle复合数据类型
来源:互联网 发布:windows高级编程教程 编辑:程序博客网 时间:2024/05/02 08:41
--type用于定于不确定的数据类型
declare
v_fd_change_left EKP_CHANGE.fd_change_left%type; --v_id是表name的id的数据类型
v_fd_change_total EKP_CHANGE.fd_change_total%type;
begin
select fd_change_left,fd_change_total
into v_fd_change_left,v_fd_change_total --只能返回一条数据
from EKP_CHANGE;
dbms_output.put_line(v_fd_change_left);
dbms_output.put_line(v_fd_change_total);
exception
when others then
dbms_output.put_line('错误');
end;
--rowtype
declare
r_name EKP_CHANGE%rowtype; --定义r_name的数据是name表一行数据对应的数据类型;
begin
select fd_change_left,fd_change_total
into r_name.fd_change_left,r_name.fd_change_total --只能返回一条数据
from EKP_CHANGE;
dbms_output.put_line(r_name.fd_change_left);
dbms_output.put_line(r_name.fd_change_total);
exception
when others then
dbms_output.put_line('错误');
end;
declare
r_ekp_change EKP_CHANGE%rowtype; --定义r_name的数据是name表一行数据对应的数据类型;
begin
select *
into r_ekp_change --这里表示r_name.id,r_name.name,r_name.grade和name表的数据对应的类型是一致的
from EKP_CHANGE;
dbms_output.put_line(r_ekp_change.fd_id);
dbms_output.put_line(r_ekp_change.fd_change_left);
end;
--数据库复合数据类型,数组varray()
declare
type str is varray(5) of varchar(18); --定义一个长度为5的数组str,每个元素为varchar(18);
strlist str:=str('I','am','xie','xing','xing'); --定义一个sreList变量来引用str数组的值;
begin
dbms_output.put_line(strlist(1)); --从1开始
dbms_output.put_line(strlist (2));
dbms_output.put_line(strlist (3));
dbms_output.put_line(strlist (4));
dbms_output.put_line(strlist (5));
end;
declare
type str is varray(5) of varchar(18); --定义一个长度为5的数组str,每个元素为varchar(18);
strlist str:=str('',''); --定义一个sreList变量来引用str数组的值;
begin
select fd_change_left,fd_change_total
into strlist(1),strlist(2)
from ekp_change;
dbms_output.put_line(strlist(1)); --从1开始
dbms_output.put_line(strlist (2));
end;
--数据库复合数据类型,数组table
declare
type str_table is table of varchar(18) index by binary_integer;
strList str_table;
begin
strList(1):='hello';
strList(2):='world'; --下标无下限
dbms_output.put_line(strList(1)||strList(2));
end;
declare
type str_table is table of EKP_CHANGE%rowtype index by binary_integer;
strList str_table;
begin
select fd_id,fd_change_left,fd_change_total
into strList(1).fd_id,strList(1).fd_change_left,strList(1).fd_change_total
from EKP_CHANGE;
dbms_output.put_line(strList(1).fd_id||strList(1).fd_change_left||strList(1).fd_change_total);
end;
--数据库复合数据类型,数组record()
declare
type v_record is record(
fd_id VARCHAR(32),
fd_change_left EKP_CHANGE.fd_change_left%type,
fd_change_total EKP_CHANGE.fd_change_total%type
);
name_record v_record;
begin
select fd_id,fd_change_left,fd_change_total
into name_record.fd_id,name_record.fd_change_left,name_record.fd_change_total
from EKP_CHANGE;
dbms_output.put_line(name_record.fd_id);
dbms_output.put_line(name_record.fd_change_left);
dbms_output.put_line(name_record.fd_change_total);
end;
declare
v_fd_change_left EKP_CHANGE.fd_change_left%type; --v_id是表name的id的数据类型
v_fd_change_total EKP_CHANGE.fd_change_total%type;
begin
select fd_change_left,fd_change_total
into v_fd_change_left,v_fd_change_total --只能返回一条数据
from EKP_CHANGE;
dbms_output.put_line(v_fd_change_left);
dbms_output.put_line(v_fd_change_total);
exception
when others then
dbms_output.put_line('错误');
end;
--rowtype
declare
r_name EKP_CHANGE%rowtype; --定义r_name的数据是name表一行数据对应的数据类型;
begin
select fd_change_left,fd_change_total
into r_name.fd_change_left,r_name.fd_change_total --只能返回一条数据
from EKP_CHANGE;
dbms_output.put_line(r_name.fd_change_left);
dbms_output.put_line(r_name.fd_change_total);
exception
when others then
dbms_output.put_line('错误');
end;
declare
r_ekp_change EKP_CHANGE%rowtype; --定义r_name的数据是name表一行数据对应的数据类型;
begin
select *
into r_ekp_change --这里表示r_name.id,r_name.name,r_name.grade和name表的数据对应的类型是一致的
from EKP_CHANGE;
dbms_output.put_line(r_ekp_change.fd_id);
dbms_output.put_line(r_ekp_change.fd_change_left);
end;
--数据库复合数据类型,数组varray()
declare
type str is varray(5) of varchar(18); --定义一个长度为5的数组str,每个元素为varchar(18);
strlist str:=str('I','am','xie','xing','xing'); --定义一个sreList变量来引用str数组的值;
begin
dbms_output.put_line(strlist(1)); --从1开始
dbms_output.put_line(strlist (2));
dbms_output.put_line(strlist (3));
dbms_output.put_line(strlist (4));
dbms_output.put_line(strlist (5));
end;
declare
type str is varray(5) of varchar(18); --定义一个长度为5的数组str,每个元素为varchar(18);
strlist str:=str('',''); --定义一个sreList变量来引用str数组的值;
begin
select fd_change_left,fd_change_total
into strlist(1),strlist(2)
from ekp_change;
dbms_output.put_line(strlist(1)); --从1开始
dbms_output.put_line(strlist (2));
end;
--数据库复合数据类型,数组table
declare
type str_table is table of varchar(18) index by binary_integer;
strList str_table;
begin
strList(1):='hello';
strList(2):='world'; --下标无下限
dbms_output.put_line(strList(1)||strList(2));
end;
declare
type str_table is table of EKP_CHANGE%rowtype index by binary_integer;
strList str_table;
begin
select fd_id,fd_change_left,fd_change_total
into strList(1).fd_id,strList(1).fd_change_left,strList(1).fd_change_total
from EKP_CHANGE;
dbms_output.put_line(strList(1).fd_id||strList(1).fd_change_left||strList(1).fd_change_total);
end;
--数据库复合数据类型,数组record()
declare
type v_record is record(
fd_id VARCHAR(32),
fd_change_left EKP_CHANGE.fd_change_left%type,
fd_change_total EKP_CHANGE.fd_change_total%type
);
name_record v_record;
begin
select fd_id,fd_change_left,fd_change_total
into name_record.fd_id,name_record.fd_change_left,name_record.fd_change_total
from EKP_CHANGE;
dbms_output.put_line(name_record.fd_id);
dbms_output.put_line(name_record.fd_change_left);
dbms_output.put_line(name_record.fd_change_total);
end;
0 0
- oracle复合数据类型
- Oracle复合数据类型
- 浅谈oracle复合数据类型
- Oracle 复合数据类型
- 浅谈oracle复合数据类型
- Oracle复合数据类型示例
- oracle复合数据类型
- 浅谈oracle复合数据类型
- oracle复合数据类型
- Oracle中复合数据类型例子
- Oracle PL/SQL复合数据类型
- 【Oracle强化】③第三章 复合数据类型
- Oracle 复合数据类型专题之PLSQL集合数据类型
- 复合数据类型
- 复合数据类型
- 复合数据类型
- 复合数据类型
- 复合数据类型
- Android 资源目录的相关知识
- file结构体
- jdk安装及环境变量配置
- 新的征途
- JSON Model转化 - (realm-json使用)
- oracle复合数据类型
- 经典SQL问题: 行转列
- HDU5706 GirlCat(简单dfs)
- java自定义异常类型
- mybatis实战教程(mybatis in action),mybatis入门到精通
- android控件ImageView加载sdcard卡,网络及res中的图片
- Spring管理
- Unity小技巧160529
- 解决block的retain cycle的警告问题