Querying time series data with the IfmxTimeSeries object
You can use a SELECT statement your Java™ program to retrieve TimeSeries data with the IfmxTimeSeries object.
String sqlCmd = "SELECT ts FROM test WHERE id = 1";
PreparedStatement pStmt = conn.prepareStatement(sqlCmd);
ResultSet rSet = pStmt.executeQuery();
com.informix.timeseries.IfmxTimeSeries ts;
rSet.next()
ts = (IfmxTimeSeries)rSet.getObject(1);
In this example, rSet is a valid java.sql.ResultSet object. After running the SELECT statement, the getObject method is used to put the time series data into the variable ts (an IfmxTimeSeries object). The TimeSeries type is at column 1 in the result set. The example assumes that an entry has been made into the conn object type map for the TimeSeries column, ts.
ts.beforeFirst();
while (ts.next())
{
java.sql.Timestamp tStamp = ts.getTimestamp(1);
int col1 = ts.getInt(2);
int col2 = ts.getInt(3);
}
The example shows that you use the beforeFirst method to position the time series cursor before the beginning of the time series and then the next method to iterate through the elements. While looping through the elements, the program uses the getTimestamp method to extract the time stamp into the variable tStamp and the getInt method to extract the first column of data into col1 and the second column into col2. The columns of a time series element are numbered, starting with the time stamp column as column 1.
When you clip a time series, the resultant time series is read-only.
The sample programs demonstrate how to retrieve and update time series data.