declare
v_student book%rowtype; --
cursor c_student(v_id binary_integer) is select * from book where id>v_id;
begin
open c_student(10);
fetch c_student into v_student;
close c_student;
dbms_output.put_line(v_student.name);
end;
请问标红的book%rowtype是什么意思?另外见到
v_tcat_id ter_ca_info.tcatd%type;
v_t_group_id con_ter_group.groupid%type;请问ter_ca_info.tcatd%type; 这个又是什么意思呢? 谢谢!
v_student book%rowtype; --
cursor c_student(v_id binary_integer) is select * from book where id>v_id;
begin
open c_student(10);
fetch c_student into v_student;
close c_student;
dbms_output.put_line(v_student.name);
end;
请问标红的book%rowtype是什么意思?另外见到
v_tcat_id ter_ca_info.tcatd%type;
v_t_group_id con_ter_group.groupid%type;请问ter_ca_info.tcatd%type; 这个又是什么意思呢? 谢谢!
这个是说v_student 是一个book表类型变量
v_tcat_id ter_ca_info.tcatd%type;
这个是说v_tcat_id是一个和ter_ca_info表里面tcatd字段一个类型的变量//%type
//如果声明的变量是直接映射到数据库的某一列上,那么就可以使用%type关键字将变量
//比如: 在熟悉ename这个字段类型的情况下可以直接声明,
//v_name varchar2(10)
当然没有这个必要,可以直接使用
v_name emp.ename%type; 结果是一样的//当数据类型发生变化时,此方法显得非常灵活。 //如果更改了列的长度,那么锚定到该列上的所有变量都会自动更改其长度;
//我们将v_name定义为varchar2(10),那么当emp表中的ename列发生变化时,
//我们得手动将v_enam更改为emp.ename相同的数据长度;
//当我们使用锚定类型后,变量就会自动进行调整。
//%rowtype
//%rowtype与%type相似;不过它将变量锚定到表的所有列,而不是锚定到某一列,返回的是一个基于数据库表定义的类型;
谢谢两位!明白了