转自:http://hi.baidu.com/mangkata/item/d72531c26126eb5dbdef69f8
oracle 中PL/SQL中type的简单用法
1.参考系统的变量类型声明一个type
declare
type myrecord is record(id varchar2(10),names varchar2(10));
real_record myrecord;
begin
select EMPNO, ENAME into real_record from emp where empno='7369';
dbms_output.put_line(real_record.id||' '||real_record.names);
end;
2.参考系统中存在的表的字段类型创建(其中emp表是SCOTT用户下的一张表)
declare
type myrecord is record(id emp.empno%type,names emp.ename%type);
real_record myrecord;
begin
select EMPNO, ENAME into real_record from emp where empno='7369';
dbms_output.put_line(real_record.id||' '||real_record.names);
end;
3.完全参照一个表来创建
declare
myrec emp%rowtype;
begin
select * into myrec from emp where empno='7369';
dbms_output.put_line(myrec.empno||' '||myrec.ename||' '||myrec.job);
end;
oracle 中PL/SQL中type的简单用法
最新推荐文章于 2023-10-10 19:59:03 发布