请问下如何在oracle存储过程中传入大量参数(比如一万个手机号码) 然后经过查询匹配后再传出大量符合的用户名
------解决方案--------------------
传一个两个电话号码,用数组也就用了,如果1W个你用数组,给数组赋初始值就能累死你,等你赋完值 2012了。
O(∩_∩)O~。
------解决方案--------------------
我的意见是
1、创建临时表
2、导入要查询的数据
3、写存储过程或触发器将结构再保存到第一步创建的表中,建议用存储过程,调试方便。
4、导出表中的查询结果
注意:如果要写程序的活,还要考虑并发的问题,如果只是考虑要查询的结果就不必了!
------解决方案--------------------
你可以使用数组参数,譬如:
TYPE var2Array IS TABLE OF VARCHAR(20) INDEX BY BINARY_INTEGER;
PROCEDURE pro__insert(tripdatas in var2Array)--taep_taxi_trip_tbl插入数据
as
datas type_table_taxi_trip:=new type_table_taxi_trip();
begin
datas.extend(tripdatas.count/5);
for i in 1 .. tripdatas.count/5 loop
datas(i):=new type_taxi_trip(tripdatas((i-1)*5+1),
tripdatas((i-1)*5+2),
tripdatas((i-1)*5+3),
tripdatas((i-1)*5+4),
to_date('' || tripdatas((i-1)*5+5) || '','yyyy-mm-dd hh24:mi:ss'));
end loop;
insert into a(license_id,vehicle_state,longitude,latitude,gps_time)
select * from the (select cast(datas as type_table_taxi_trip) from dual);
commit;
end ;