查询语句:select * from table_name where id='1'; 在jdbc中我们可以这样查询String sql = "select * from table_name where id=?";
PreparedStatement ps = conn.preparedStatement(sql);
ps.setString(1, "1");
ps.executeQuery();在存储过程中可以这么用
create or replace procedure(vId in char) as
....
begin
....
select name into ..from table_name where id=vId;
....
end;通过 ‘?’占位符传参数。
但是这样id的值只能有一个。如果我想批量查询,如:select * from table_name where id in ('1','2','3'.....);就是in里的数据个数不固定。在jdbc中该如何使用?
在存储过程中又怎么传递参数呢?(不要拼接字符串)求指点.
PreparedStatement ps = conn.preparedStatement(sql);
ps.setString(1, "1");
ps.executeQuery();在存储过程中可以这么用
create or replace procedure(vId in char) as
....
begin
....
select name into ..from table_name where id=vId;
....
end;通过 ‘?’占位符传参数。
但是这样id的值只能有一个。如果我想批量查询,如:select * from table_name where id in ('1','2','3'.....);就是in里的数据个数不固定。在jdbc中该如何使用?
在存储过程中又怎么传递参数呢?(不要拼接字符串)求指点.
解决方案 »
- 求oracle SQL语句一下插入多行记录。
- 求一个function ,以CE/CO 为外循环,以0-9,A-Z 产生流水号,新手,求解
- ORacle imp 时产生问题 急求帮助,请大家看看为什么CMS_CONTENTS导不进去
- oracle 中有两个表如何定时更新2个表的数据?
- 在线等待,pro*c出错?急!
- 有没有在oracle9.2下用过$ORACLE_HOME/bin/dbstart和dbshut脚本进行数据库的启动和关闭呀?
- sql语句的小问题
- 如何在oracle8i的dba下导出导入数据表呢?
- 新手关于Oracle的几个问题,请高手解答
- 请问高手:如何配置并行服务器?
- oracle锁问题
- ibm的infoshpere cdc从哪下载,有谁了解?
v_ids='1,2,3';
如果表的数据量小,可以直接用LIKE查询:
select * from table_name where ','||v_ids||',' LIKE '%,'||id||',%' ;
如果数据量大,那么先把v_ids拆分出来插入到临时表中,再查询:
select * from table_name where id (select * from temp_tab)