oracle学习总结---record
2017-01-18 20:57
309 查看
--记录变量学习
--基本语法
--type 记录型变量的名称 is record (
--变量名 变量类型,
--变量名 变量类型。
--);
--实例:创建一个过程,用于参数出入员工编号,运用记录型变量打印员工姓名和薪资
create or replace procedure pro2(v_in_empno in emp.empno%type)
is
--定义记录型变量
type recordNo is record (
v_name emp.ename%type,
v_sal emp.sal%type
);
rn recordNo;
begin
select ename,sal into rn.v_name,rn.v_sal from emp where empno = v_in_empno;
dbms_output.put_line('name='||rn.v_name || ' sal ='||rn.v_sal);
end;
--创建块,用于调用过程
declare
begin
pro2(7839);
end;
--pl/sql表变量学习
--基本语法
--type pl/sql表变量类型 is table of 参考字段 index by binary_integer;
--实例:创建一个幻术用于参数输入员工编号,用pl/sql变量参数答应员工名。
create or replace function fun1(v_in_empno in emp.empno%type)
return emp.ename%type
is
--定义pl/sql表类型
type chen_table is table of emp.ename%type index by binary_integer;
--定义pl/sql表变量
v_chen_table chen_table;
begin
select ename into v_chen_table(1) from emp where empno = v_in_empno;
dbms_output.put_line('name is ' ||v_chen_table(1));
return v_chen_table(1);
end;
--创建一个块,用于创建调用fun1
declare
v_name emp.ename%type;
begin
v_name := fun1(7369);
end;
--基本语法
--type 记录型变量的名称 is record (
--变量名 变量类型,
--变量名 变量类型。
--);
--实例:创建一个过程,用于参数出入员工编号,运用记录型变量打印员工姓名和薪资
create or replace procedure pro2(v_in_empno in emp.empno%type)
is
--定义记录型变量
type recordNo is record (
v_name emp.ename%type,
v_sal emp.sal%type
);
rn recordNo;
begin
select ename,sal into rn.v_name,rn.v_sal from emp where empno = v_in_empno;
dbms_output.put_line('name='||rn.v_name || ' sal ='||rn.v_sal);
end;
--创建块,用于调用过程
declare
begin
pro2(7839);
end;
--pl/sql表变量学习
--基本语法
--type pl/sql表变量类型 is table of 参考字段 index by binary_integer;
--实例:创建一个幻术用于参数输入员工编号,用pl/sql变量参数答应员工名。
create or replace function fun1(v_in_empno in emp.empno%type)
return emp.ename%type
is
--定义pl/sql表类型
type chen_table is table of emp.ename%type index by binary_integer;
--定义pl/sql表变量
v_chen_table chen_table;
begin
select ename into v_chen_table(1) from emp where empno = v_in_empno;
dbms_output.put_line('name is ' ||v_chen_table(1));
return v_chen_table(1);
end;
--创建一个块,用于创建调用fun1
declare
v_name emp.ename%type;
begin
v_name := fun1(7369);
end;
相关文章推荐
- oracle学习总结一(基础)
- oracle学习总结三(bulk collect用法)
- oracle学习总结(二)
- Oracle学习总结1
- 总结ORACLE学习--8023
- oracle的学习小总结及其与sqlserver小区别
- oracle数据库学习总结:数据库概念及相关信息查看
- oracle学习总结(二)
- oracle学习总结(一)---ROWID
- Oracle字符集问题整理 (学习心得与网摘总结)
- oracle学习总结三(创建脚本)
- Oracle学习个人总结
- [原]ADO.net学习和总结(C#,Oracle)
- oracle学习总结(一)
- oracle学习总结二(转义字符)
- oracle学习总结二(转义字符)
- oracle学习总结(一)---ROWID
- oracle学习总结(一)---ROWID
- Oracle 10g 内存结构体系学习总结
- 在校生如何开始学习数据库(五) oracle数据学习总结