set serveroutput on;
declare
cursor tb_Test is select * from test;
col1 tb_Test.TESTID%type;
col2 tb_Test.TESTNAME%type;
col3 tb_Test.TESTVALUE%type;
col4 tb_Test.TESTDATE%type;
begin
open tb_Test;
fetch tb_Test into col1,col2,col3,col4;
dbms_output.put_line(to_char(col1)||' , '||to_char(col2) ||' , '||to_char(col3));
close tb_Test;
end;
/执行时说第10行有问题,也找不出来是什么问题
declare
cursor tb_Test is select * from test;
col1 tb_Test.TESTID%type;
col2 tb_Test.TESTNAME%type;
col3 tb_Test.TESTVALUE%type;
col4 tb_Test.TESTDATE%type;
begin
open tb_Test;
fetch tb_Test into col1,col2,col3,col4;
dbms_output.put_line(to_char(col1)||' , '||to_char(col2) ||' , '||to_char(col3));
close tb_Test;
end;
/执行时说第10行有问题,也找不出来是什么问题
解决方案 »
- 关于表空间
- oracle 异构服务通用连接怎么连db2用db_link
- 一个关于批量分页查询的很奇怪的问题,诚请高手出马!!(有几个高手都没想明白的问题)
- 海量关系数据生成 是什么啊 ??????、怎么生成?????????
- 怎样在ORACLE中将一个字段中的字符查询处理展示的时候分成多行
- 在ORACLE过程中字符串"8;26;14;24;"怎样循环插入表中!
- pl/sql执行sql脚本的问题
- 还是一个sql查询问题(高手请进,beckhambobo请进),谢谢啦
- 如何select出表中为空的所有字段?
- 服务器管理器用不了怎么办?
- ORA-00600: 内部错误代码,参数: [1236]
- 请问如何在用户登录后只显示自有表和视图,而不显示其他视图
col2 tb_Test.TESTNAME%type;
col3 tb_Test.TESTVALUE%type;
col4 tb_Test.TESTDATE%type;
改为
col1 test.TESTID%type;
col2 test.TESTNAME%type;
col3 test.TESTVALUE%type;
col4 test.TESTDATE%type;
这是格式日期的
不用dbms_output.put_line的话我也不知道打印
都用dbms_output.put_line
你为什么不想用它晕.
如果用for语句来输出,怎样才晓得找开的游标是空的,然后跳出循环
cursor tb_Test is select * from test;
col1 tb_Test.TESTID%type;
col2 tb_Test.TESTNAME%type;
col3 tb_Test.TESTVALUE%type;
col4 tb_Test.TESTDATE%type;
begin
open tb_Test;
fetch tb_Test into col1,col2,col3,col4;
exit when tb_Test%notfound;
dbms_output.put_line(to_char(col1) ¦ ¦' , ' ¦ ¦to_char(col2) ¦ ¦' , ' ¦ ¦to_char(col3));
close tb_Test;
加这句话
exit when tb_Test%notfound;
declare
cursor tb_Test(argId TEST.TESTID%type) is select * from test where testid=argId;
rTemp tb_Test%rowtype;
iTemp Test.TESTID%type;
begin
for iTemp in 1..10 loop
open tb_Test(iTemp);
exit when tb_Test%notfound;
fetch tb_Test into rTemp;
dbms_output.put_line(to_char(rTemp.TESTID)||' , '||to_char(rTemp.TESTNAME) ||' , '||to_char(rTemp.TESTVALUE)||' , ' || to_char(rTemp.TESTDATE,'yyyy-mm-dd'));
close tb_Test;
end loop;
end;
fetch tb_Test into rTemp;
这两行调换一下顺序
和close cursor
放到循环外面