Name

Connection.isselect — determine if an SQL statement is a select or an update

Synopsis

boolean Connection.isselect ( sql);  
string   sql;

Description

Use this method to determine if an arbitrary SQL statement is a select statement or an update statement. Select statements should be opened using Connection.openrs() whereas update statements should be executed using Connection.execute(). This method returns true if it is an SQL select statement. This does not guarantee that it is a valid SQL query.

The SQL query should be on a single line without comments or leading or trailing whitespace.

Example 62. Connection.isselect Example

if(conn.isselect(sql))
{
    Recordet rs = conn.openrs(sql);

    if(rs != null)
    {
        // . . .
        rs.close();
    }
}
else
{
    int rowsaffected = conn.execute(sql);
}

See Also

Data sources and database access in RSP is explained in the section called “Accessing Databases”