How to absolute records from SQLJ positional Iterators
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Shiraf_Ziyard
Posted On:   Wednesday, October 22, 2003 11:13 PM

I have created a test class to read some records using scrollable positional iterator. This is the way I have written the code for it. import sqlj.runtime.*; import sqlj.runtime.ref.*; import java.sql.*; import java.math.BigDecimal; /* Iterator class declaration */ #sql iterator TransactionData implements Scrollable (Timestamp, BigDecimal, BigDecimal, String); public class ReadTxDataTest { public static void readTxnData() { TransactionData posIt; Timestamp date = null; BigDecimal bamt = null; BigDecimal famt = null; String curr = null; long startTime = System.currentTimeMillis(); int i = 1; try { #sql   More>>

I have created a test class to read some records using scrollable positional iterator. This is the way I have written the code for it.




			
import sqlj.runtime.*;
import sqlj.runtime.ref.*;
import java.sql.*;
import java.math.BigDecimal;

/* Iterator class declaration */
#sql iterator TransactionData implements Scrollable (Timestamp, BigDecimal, BigDecimal, String);

public class ReadTxDataTest {

public static void readTxnData() {
TransactionData posIt;
Timestamp date = null;
BigDecimal bamt = null;
BigDecimal famt = null;
String curr = null;
long startTime = System.currentTimeMillis();
int i = 1;
try {
#sql posIt = {SELECT tk_ft_txndate, tk_ft_baseamt, tk_ft_fcamt, tk_ft_curr
FROM TRKFDRTXN
WHERE tk_ft_domcode='5000'};
while (true) {
#sql { FETCH ABSOLUTE :i FROM :posIt INTO :date, :bamt, :famt, :curr};
if (posIt.endFetch()) break;
System.out.println("date = "+date.toString());
i +=1;
}
posIt.close();
long endTime = System.currentTimeMillis();
System.out.println("Total time taken : " + ((endTime - startTime) / 1000) + " sec.");
} catch (Exception e){
e.printStackTrace();
}
}
}




The problem I'm having is when I run this code even though query returns 10 records Im not able to retrieve any of them. The code get breaked from endFetch() method. When I replce the FETCH statement to #sql {FETCH : posIt INTO :date, :bamt, :famt, :curr}. I'm able to get all 10 records. Fetch NEXT,FIRST,LAST too are working but not ABSOLUTE or RELATIVE. What might be the problem ? I'm using Oracle 9i DB with Oracle SQLJ 9.2

   <<Less
About | Sitemap | Contact