我们有一个 SQLJ 文件,我们在其中指定了一个迭代器来从表中获取多条记录。目前,我们正在尝试通过一次从总共 300 条记录中提取 50 条记录来将 300 条记录从中间表上传到实际表。
我们面临的问题是,每次获取都会创建 50 个迭代器,其中 1 个游标是 DICTIONARY LOOKUP CURSOR CACHED,49 个是 OPEN-RECURSIVE。在遍历迭代器之后,我们在 finally 块中有一个 close 调用,但这会关闭一个 one 游标,剩下 48 个 OPEN-RECURSIVE 游标和 1 个 DICTIONARY LOOKUP CURSOR CACHED。我想知道是否有任何特定的方法可以关闭所有这些。我曾尝试在网络上查看,但在这种情况下并没有真正遇到太多。
#sql public static iterator UploadDetailsList(BigDecimal ID, String FUNCTION_ID,String TABLE_NAME)
#sql public static iterator UploadDetailsListAnother(BigDecimal ID, String FUNCTION_ID,String TABLE_NAME)
public List<UploadDto> getRecords(UploadDto newDto,int fromRowNo){
//fromRowNo is sent as 0
int maxResults=50;
int toRowNum= fromRowNo + maxResults;
UploadDetailsList uploadDetailsList=null;
UploadDetailsListAnother uploadDetailsListAnother=null;
try{
#sql uploadDetailsList = {SELECT ID,FUNCTION_ID,TABLE_NAME FROM UPLOAD_TABLE WHERE STATUS= 'U' AND ROWNUM BETWEEN :fromRowNo AND :toRowNum};
while(uploadDetailsList.next()){
//populate details to Dto object
try{
#sql uploadDetailsListAnother = {SELECT ID,FUNCTION_ID,TABLE_NAME FROM UPLOAD_TABLE WHERE STATUS= 'U' AND ROWNUM BETWEEN :fromRowNo AND :toRowNum};
while(uploadDetailsListAnother.next()){
//populate details to Dto object
}
}
catch(Exception e){
//print error
}
}
}
catch(Exception e){
//print error
}
finally{
try{
dbg("Inside finally in List<UploadDto> getRecords(UploadDto newDto,int fromRowNo)");
if(uploadDetailsList != null){
dbg("Closing uploadDetailsList");
uploadDetailsList.close();
}
if(uploadDetailsListAnother != null){
dbg("Closing uploadDetailsListAnother");
uploadDetailsListAnother.close();
}
}
catch(Exception e){
//print error
}
}
}
有人可以让我知道我哪里出错了,或者我可能遗漏了什么吗?