Skip Headers

# Using a ValueReadQuery

Previous

Next

You can use a `ValueReadQuery` to read a single data value (that is, one field). A single data value is returned, or null if no rows are returned, as Example: Using a ValueReadQuery shows.

Using a ValueReadQuery

    ValueReadQuery valueReadQuery = new ValueReadQuery();
    valueReadQuery.setSQLString("SELECT DISTINCT CURRENT TIMESTAMP FROM SYSTABLES");

    // result is a single Object value
    Object result = session.executeQuery(valueReadQuery);

WARNING: Allowing an unverified SQL string to be passed into methods (for example: `setSQLString` method) makes your application vulnerable to SQL injection attacks.