日期:2014-05-16  浏览次数:20379 次

使用数组作为查询参数
1、初始化数组参数的类型。
语句如下:
		String[] arrayRuleNo = ruleNos.split(",");
		String C_ORACLE_VARCHAR = "TYP_AC_VARCHAR2";
		
		Connection conn = DaoUtil.getConnection(DaoTools.getConnName()).getMetaData().getConnection();
		
		ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor(C_ORACLE_VARCHAR, conn);
		ARRAY oraARRAY = new ARRAY(descriptor, conn, arrayRuleNo);


2、组装并执行SQL
----------起始略-----------
v_sql := 'SELECT a.query_no, a.NAME FROM Xxxx a WHERE a.query_no IN (';
		
				FOR i IN in_rulenos.FIRST .. in_rulenos.LAST
				LOOP
						v_sql := v_sql || in_rulenos(i) || ',';
				END LOOP;
				v_sql := substr(v_sql, 1, length(v_sql) - 1);
				v_sql := v_sql || ') ORDER BY a.query_no DESC';
				OPEN out_rules_name FOR v_sql;
----------结束略-----------