com.esri.sde.sdk.client
Class SeQuery

java.lang.Object
  extended by com.esri.sde.sdk.client.SeStreamOp
      extended by com.esri.sde.sdk.client.SeQuery

public class SeQuery
extends SeStreamOp

Used to submit a query to an ArcSDE instance.

A typical SeQuery operation sequence is:

1) Create an SeQuery.

2) Prepare the query.

3) Execute a statement or spatial query.

4) Fetch a single SeRow from the SeQuery.

5) Retrieve column values and feature geometry from the fetched SeRow.

6) Close the SeQuery at the end of a series of fetches.

See Also:
SeRow

Field Summary
static short SE_ATTRIBUTE_FIRST
           
static short SE_OPTIMIZE
           
static short SE_SPATIAL_FIRST
           
static int STREAM_CLOSED
           
static int STREAM_EXECUTE
           
static int STREAM_FETCH
           
static int STREAM_FILE_QUERY
           
static int STREAM_FINISHED
           
static int STREAM_INACTIVE
           
static int STREAM_INITIALIZE
           
static int STREAM_LAYER_QUERY
           
static int STREAM_LOG_QUERY
           
static int STREAM_NONE
           
static int STREAM_PREPARE_SQL
           
 
Constructor Summary
SeQuery(SeConnection conn)
          Creates an SeQuery object given an SeConnection.
SeQuery(SeConnection conn, java.lang.String[] columns, SeSqlConstruct construct)
          Creates an SeQuery object given an SeConnection, an array of column names, and an SeSqlConstruct.
 
Method Summary
 SeExtent calculateLayerExtent(SeQueryInfo qInfo)
          Returns the envelope for all features within the layer that pass any SQL construct, state, or spatial constraints for the stream.
 SeLayer.SeLayerStats calculateLayerStatistics(SeQueryInfo qInfo)
          Returns a set of statistics for a layer.
 SeTable.SeTableStats calculateTableStatistics(java.lang.String column, int mask, SeQueryInfo qInfo, int maxDistinct)
          Returns a set of statistics for a column in a table.
 SeRow fetch()
          Fetches an SeRow of data.
 SeRow fetchRow(java.lang.String table, SeObjectId seRowId, java.lang.String[] columns)
          Fetches a single row based on the feature id.
 boolean getInvalidShapeMode()
          Returns true if fetching invalid shape is allowed.
 int getNumColumns()
          Returns the number of columns on the query.
 void prepareQuery()
          Initializes a stream with a query using a selected set of columns and an SeSqlConstruct object for the where clause.
 void prepareQuery(java.lang.String[] columns, SeSqlConstruct construct)
          Initializes a stream with a query using a selected set of columns and an SeSqlConstruct object for the where clause.
 void prepareQueryInfo(SeQueryInfo qInfo)
          Initializes a stream with a query using an SeQueryInfo object.The SE_QUERYINFO structure includes parameters to define tables, columns, where clause, query type, ORDER BY clauses and DBMS hints.
 void prepareQueryLogfile(java.lang.String logfile)
          Initializes a stream with a query using a selected set of columns and an SeSqlConstruct object for the where clause.
 java.util.Vector prepareQueryRowIdByUuid(java.lang.String table, java.lang.String uuidColumn, java.lang.String[] uuids)
          Initializes a stream with a query using a selected set of columns and an SeSqlConstruct object for the where clause.
 void prepareSql(java.lang.String sqlStatement)
          Tells the server to prepare the sql statement for execution.
 void queryRasterTile(SeRasterConstraint rasterConstraint)
          Prepares raster tile query.
 void setInvalidShapeMode(boolean fetchInvalidShape)
          Sets the truth for fetching invalid shape.
 void setRasterConstraint(SeRasterConstraint rasterConstraint)
          Sets raster constraint query.
 void setSpatialConstraints(short searchOrder, boolean calcMasks, SeFilter[] filters)
          Sets the spatial filters on the query.
 
Methods inherited from class com.esri.sde.sdk.client.SeStreamOp
cancel, close, describeColumn, equivalenceRows, execute, flushBufferedWrites, inProgress, setDynamicParameters, setLogfile, setRowLocking, setState, unequivalenceRows
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STREAM_FILE_QUERY

public static final int STREAM_FILE_QUERY
See Also:
Constant Field Values

STREAM_LAYER_QUERY

public static final int STREAM_LAYER_QUERY
See Also:
Constant Field Values

STREAM_LOG_QUERY

public static final int STREAM_LOG_QUERY
See Also:
Constant Field Values

STREAM_NONE

public static final int STREAM_NONE
See Also:
Constant Field Values

STREAM_PREPARE_SQL

public static final int STREAM_PREPARE_SQL
See Also:
Constant Field Values

STREAM_CLOSED

public static final int STREAM_CLOSED
See Also:
Constant Field Values

STREAM_INACTIVE

public static final int STREAM_INACTIVE
See Also:
Constant Field Values

STREAM_INITIALIZE

public static final int STREAM_INITIALIZE
See Also:
Constant Field Values

STREAM_EXECUTE

public static final int STREAM_EXECUTE
See Also:
Constant Field Values

STREAM_FETCH

public static final int STREAM_FETCH
See Also:
Constant Field Values

STREAM_FINISHED

public static final int STREAM_FINISHED
See Also:
Constant Field Values

SE_ATTRIBUTE_FIRST

public static final short SE_ATTRIBUTE_FIRST
See Also:
Constant Field Values

SE_SPATIAL_FIRST

public static final short SE_SPATIAL_FIRST
See Also:
Constant Field Values

SE_OPTIMIZE

public static final short SE_OPTIMIZE
See Also:
Constant Field Values
Constructor Detail

SeQuery

public SeQuery(SeConnection conn)
        throws SeException
Creates an SeQuery object given an SeConnection. This creates a stream between the ArcSDE client and server, which is used to transmit features and/or attribute data.

Throws:
SeException

SeQuery

public SeQuery(SeConnection conn,
               java.lang.String[] columns,
               SeSqlConstruct construct)
        throws SeException
Creates an SeQuery object given an SeConnection, an array of column names, and an SeSqlConstruct. This creates a stream between the ArcSDE client and server, which is used to transmit features and/or attribute data.

Throws:
SeException
Method Detail

prepareQuery

public void prepareQuery()
                  throws SeException
Initializes a stream with a query using a selected set of columns and an SeSqlConstruct object for the where clause. The where clause can't contain any ORDER BY or GROUP BY clauses.

Throws:
SeException

prepareQuery

public void prepareQuery(java.lang.String[] columns,
                         SeSqlConstruct construct)
                  throws SeException
Initializes a stream with a query using a selected set of columns and an SeSqlConstruct object for the where clause. The where clause can't contain any ORDER BY or GROUP BY clauses.

Throws:
SeException

prepareQueryRowIdByUuid

public java.util.Vector prepareQueryRowIdByUuid(java.lang.String table,
                                                java.lang.String uuidColumn,
                                                java.lang.String[] uuids)
                                         throws SeException
Initializes a stream with a query using a selected set of columns and an SeSqlConstruct object for the where clause. The where clause can't contain any ORDER BY or GROUP BY clauses.

Throws:
SeException

prepareQueryLogfile

public void prepareQueryLogfile(java.lang.String logfile)
                         throws SeException
Initializes a stream with a query using a selected set of columns and an SeSqlConstruct object for the where clause. The logfile identifies which features the selection will process. The where clause can't contain any ORDER BY or GROUP BY clauses.

Parameters:
logfile - the logfile name.
Throws:
SeException

prepareQueryInfo

public void prepareQueryInfo(SeQueryInfo qInfo)
                      throws SeException
Initializes a stream with a query using an SeQueryInfo object.The SE_QUERYINFO structure includes parameters to define tables, columns, where clause, query type, ORDER BY clauses and DBMS hints.

Parameters:
qInfo - the SeQueryInfo object handle.
Throws:
SeException

getNumColumns

public int getNumColumns()
                  throws SeException
Returns the number of columns on the query.

Throws:
SeException

prepareSql

public void prepareSql(java.lang.String sqlStatement)
                throws SeException
Tells the server to prepare the sql statement for execution. The sqlStatement is executed by the underlying database when the execute() method is invoked.

Parameters:
sqlStatement - any SQL statement supported by the underlying DBMS.
Throws:
SeException

fetch

public SeRow fetch()
            throws SeException
Fetches an SeRow of data.

Throws:
SeException

fetchRow

public SeRow fetchRow(java.lang.String table,
                      SeObjectId seRowId,
                      java.lang.String[] columns)
               throws SeException
Fetches a single row based on the feature id. A call to this method immeadiately retrieves the row from the database. execute need not be called.

Parameters:
table - the name of the table to fetch data from.
seRowId - the feature or row id of the row to be fetched.
columns - the list of columns to be retrieved from the table.
Throws:
SeException

calculateLayerStatistics

public SeLayer.SeLayerStats calculateLayerStatistics(SeQueryInfo qInfo)
                                              throws SeException
Returns a set of statistics for a layer. You must have query access to the layer. This function reads the entire feature table and can be very expensive on a large layer. The query info object should contain the layer's table name as the sql construct's first table.

Parameters:
qInfo - SeQueryInfo object handle.
Returns:
SeLayer.SeLayerStats
Throws:
SeException

calculateTableStatistics

public SeTable.SeTableStats calculateTableStatistics(java.lang.String column,
                                                     int mask,
                                                     SeQueryInfo qInfo,
                                                     int maxDistinct)
                                              throws SeException
Returns a set of statistics for a column in a table. You can also use a SQL column expression in the place of the column parameter (e.g., "COLUMN_1 + COLUMN_2 * 10"). The expression must be supported by the underlying DBMS.

The mask parameter uses a bit-mask to determine which statistics to calculate. The possible values are

Use the query info structure to specify the table and any optional where clause. You can also join tables.

When computing statistics, in order for any spatial constraint set on the stream to be used, the spatial constraint must have the mask paramter set to true. If this parameter is set to false, the spatial constraint is just ignored. The calculate statistics function then returns the statistics for the entire table.

If the max_distinct parameter is zero, the MAXDISTINCT value from the giomgr.defs file is used to limit the number of values. If that value is zero, the number of distinct values is unlimited.

Parameters:
column - the column name.
mask - the statistics bit mask.
qInfo - SeQueryInfo object handle.
maxDistinct - the maximum number of distinct values.
Returns:
SeTable.SeTableStats
Throws:
SeException
See Also:
setSpatialConstraints(short, boolean, com.esri.sde.sdk.client.SeFilter[])

calculateLayerExtent

public SeExtent calculateLayerExtent(SeQueryInfo qInfo)
                              throws SeException
Returns the envelope for all features within the layer that pass any SQL construct, state, or spatial constraints for the stream.

Parameters:
qInfo - SeQueryInfo object handle.
Returns:
SeExtent
Throws:
SeException

getInvalidShapeMode

public boolean getInvalidShapeMode()
                            throws SeException
Returns true if fetching invalid shape is allowed.

Throws:
SeException

setInvalidShapeMode

public void setInvalidShapeMode(boolean fetchInvalidShape)
                         throws SeException
Sets the truth for fetching invalid shape.

Throws:
SeException

setSpatialConstraints

public void setSpatialConstraints(short searchOrder,
                                  boolean calcMasks,
                                  SeFilter[] filters)
                           throws SeException
Sets the spatial filters on the query.

SEARCH ORDERS:

SE_ATTRIBUTE_FIRST - do not use spatial index.

SE_SPATIAL_FIRST - use spatial index.

SE_OPTIMIZE - let SDE decide.

Parameters:
searchOrder - the search order.
calcMasks - if true, uses the spatial query to calculate statistics.
filters - the array of filters to be applied as spatial constraints.
Throws:
SeException

setRasterConstraint

public void setRasterConstraint(SeRasterConstraint rasterConstraint)
                         throws SeException
Sets raster constraint query.

Parameters:
rasterConstraint - SeRasterConstraint object handle.
Throws:
SeException - if an error occurs

queryRasterTile

public void queryRasterTile(SeRasterConstraint rasterConstraint)
                     throws SeException
Prepares raster tile query.

Parameters:
rasterConstraint - SeRasterConstraint object handle.
Throws:
SeException - if an error occurs