具有可变列/表/条件的Oracle游标 [英] Oracle cursor with variable columns/tables/criteria

查看:102
本文介绍了具有可变列/表/条件的Oracle游标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当表名,列和where子句变化时,我需要打开一个游标.表名等将作为参数传递.例如

I need to open a cursor while table name, columns and where clause are varying. The table name etc will be passed as parameter. For example

CURSOR batch_cur
IS
SELECT a.col_1, b.col_1
FROM table_1 a inner join table_2 b 
ON a.col_2 = b.col_2
WHERE a.col_3 = 123

此处,预计的列,表名称,连接条件和where子句将作为参数传递.打开后,我需要遍历并处理每个提取的记录.

Here, projected columns, table names, join criteria and where clause will be passed as parameters. Once opened, i need to loop through and process each fetched record.

推荐答案

您需要使用请注意为数据值使用绑定变量-如果您将多次使用不同的值重复使用此变量,则非常重要.

Note the use of a bind variable for the data value - very important if you will re-use this many times with different values.

这篇关于具有可变列/表/条件的Oracle游标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆