如下表
学生信息tblemp
id name gender
101 张三 1
201 李四 2
301 王五
输出性别信息时将数字转换为汉字,如果是1输出男、2输出女。
declare
cursor c is select * from tblemp;
begin
for i in c loop
dbms_output.put_line(i.id||i.name);//问题出现在这一行 输出结果如下:
if(i.gender =1) then dbms_output.put_line('男'); 101张三
elsif (i.gender=2) then dbms_output.put_line('女'); 男
end if; 201李四
end loop; 女
end; 301王五
begin
dbms_output.put_line('213');
end;如果把有问题的那一行换成 dbms_output.put(i.id||i.name);
输出结果则变为:
101张三男
201李四女自己写的测试语句:
begin
dbms_output.put_line('213');
end;
结果输出213begin
dbms_output.put('213');
end;
结果什么也不输出。
本人所用环境为PLSQL Developer oracle 11g
学生信息tblemp
id name gender
101 张三 1
201 李四 2
301 王五
输出性别信息时将数字转换为汉字,如果是1输出男、2输出女。
declare
cursor c is select * from tblemp;
begin
for i in c loop
dbms_output.put_line(i.id||i.name);//问题出现在这一行 输出结果如下:
if(i.gender =1) then dbms_output.put_line('男'); 101张三
elsif (i.gender=2) then dbms_output.put_line('女'); 男
end if; 201李四
end loop; 女
end; 301王五
begin
dbms_output.put_line('213');
end;如果把有问题的那一行换成 dbms_output.put(i.id||i.name);
输出结果则变为:
101张三男
201李四女自己写的测试语句:
begin
dbms_output.put_line('213');
end;
结果输出213begin
dbms_output.put('213');
end;
结果什么也不输出。
本人所用环境为PLSQL Developer oracle 11g
之后,再试试put
当使用DBMS_OUTPUT.PUT_LINE()时,会在数据行尾加一个换行符,此时会将缓冲的内容输出。当使用DBMS_OUTPUT.PUT()时,必须手动加入一个换行符(通过调用NEW_LINE(),GET_LINE(),GET_LINES())
此时才会将缓冲区内容输出。实测步骤:-- Created on 2012-01-01 by ADMINISTRATOR
declare
-- Local variables here
i integer;
begin
dbms_output.put('213');
dbms_output.new_line();
end;
这样就可以输出213了。