for c_cur in cur loop
v_custcd := c_cur.CUST_CD;
v_sectcd := c_cur.SECT_CD;
dbms_output.put_line('The CUST_CD is ' || v_custcd);
dbms_output.put_line('The SECT_CD is ' || v_sectcd);
if (v_sectcd='nosuchsectcd') then
tempSql := 'delete from T_QUEST_DTL where CUST_CD=' || v_custcd || 'current of cur';
else
tempSql := 'update T_QUEST_DTL set QUEST_DIV=' || '(select QUEST_DIV from T_QUEST_DTL where QUEST_TXT_1='~2600'' ||
' and SECT_CD='|| v_sectcd || ')';
dbms_output.put_line('The tempSql is ' || tempSql);
end if;
update_cur := dbms_sql.open_cursor;
dbms_sql.parse(update_cur, tempSql, dbms_sql.v7);
proccesed := dbms_sql.execute(update_cur);
dbms_sql.close(update_cur);
end loop;
commit;
close cur;
在上一段程序中会根据select语句赋给c_cur的值来判断对当前的行进行删除或者更新,不知道这样写对不对,
还有current of cursor是不是对取出的当前行进行操作,其他的纪录不会受到影响,where后面除了current of cursor还可以加其他的条件吗?如果可以的话是用AND来连接?
谢谢大家,
v_custcd := c_cur.CUST_CD;
v_sectcd := c_cur.SECT_CD;
dbms_output.put_line('The CUST_CD is ' || v_custcd);
dbms_output.put_line('The SECT_CD is ' || v_sectcd);
if (v_sectcd='nosuchsectcd') then
tempSql := 'delete from T_QUEST_DTL where CUST_CD=' || v_custcd || 'current of cur';
else
tempSql := 'update T_QUEST_DTL set QUEST_DIV=' || '(select QUEST_DIV from T_QUEST_DTL where QUEST_TXT_1='~2600'' ||
' and SECT_CD='|| v_sectcd || ')';
dbms_output.put_line('The tempSql is ' || tempSql);
end if;
update_cur := dbms_sql.open_cursor;
dbms_sql.parse(update_cur, tempSql, dbms_sql.v7);
proccesed := dbms_sql.execute(update_cur);
dbms_sql.close(update_cur);
end loop;
commit;
close cur;
在上一段程序中会根据select语句赋给c_cur的值来判断对当前的行进行删除或者更新,不知道这样写对不对,
还有current of cursor是不是对取出的当前行进行操作,其他的纪录不会受到影响,where后面除了current of cursor还可以加其他的条件吗?如果可以的话是用AND来连接?
谢谢大家,
解决方案 »
- 一个select的问题、
- 将oracle数据库前10条数据的日期字段update,在线等
- ORACLE 1521出现N多TIME_WAIT的问题
- 求一完整的物化视图过程及语句
- SQL2000存储过程声明变量了,但却报没声明的错误
- ORA-01446:无法从含DISTINCT, GROUP BY等子句的视图中选择ROWID
- 执行:exec dbms_output.enable(9999);错误
- 关于Pro*C连接成C语言可执行文件的问题,紧急求助!
- 在Oracle中如何用SQL取出前几条纪录?(在线等待)
- 如何使用archivelog模式下自動生成的文件對數據庫進行恢復﹖
- 100%送分!!!非常简单的问题:连接ORACLE 数据库问题++++++++++++++++++++++++++++++++++
- 高手们,刚接触oracle DB 那里有关于Oracle的专业论坛!
不清楚oracle是否支持
建议表中建立唯一索引,然后根据唯一索引删除或更新数据
v_custcd := c_cur.cust_cd;
v_sectcd := c_cur.sect_cd;
dbms_output.put_line ('The CUST_CD is ' || v_custcd);
dbms_output.put_line ('The SECT_CD is ' || v_sectcd); if (v_sectcd = 'nosuchsectcd') then
tempsql :=
'delete from T_QUEST_DTL where CUST_CD=' || v_custcd || 'current of cur';
else
tempsql :=
'update T_QUEST_DTL set QUEST_DIV='
|| '(select QUEST_DIV from T_QUEST_DTL where QUEST_TXT_1=''~2600''' --两个连续的单引号表示在字符串中用到一个引号
|| ' and SECT_CD='
|| v_sectcd
|| ')';
dbms_output.put_line ('The tempSql is ' || tempsql);
end if; update_cur := dbms_sql.open_cursor;
dbms_sql.parse (update_cur, tempsql, dbms_sql.v7);
proccesed := dbms_sql.execute (update_cur);
dbms_sql.close (update_cur);
end loop;2、current of cursof就是处理当前cursor 所在行,举例:
for i in cur loop
update mytable
set col1 = '1'
where current of cur;
end loop;