Developing Applications Using the UltraLite C++ Component
Accessing data using dynamic SQL
The SELECT statement allows you to retrieve information from the database. When you execute a SELECT statement, the PreparedStatement.ExecuteQuery method returns a ResultSet object.
For more information, see Class UltraLite_PreparedStatement_iface.
To execute a SELECT statement
Create a new prepared statement and result set.
PreparedStatement * prepStmt;
Assign a prepared statement to your newly created PreparedStatement object.
ULValue sqltext( "SELECT MyColumn FROM MyTable" ); prepStmt = conn->PrepareStatement( sqltext );
Execute the statement.
In the following code, the result of the SELECT query contain a string, which is output to a command prompt.
#define MAX_NAME_LEN 100
ULValue mycol;
ResultSet * rs = stmt->ExecuteQuery();
rs->BeforeFirst();
while( rs->Next() ){
char mycol[ MAX_NAME_LEN ];
val = rs->Get( 1 );
val.GetString( mycol, MAX_NAME_LEN );
printf( "mycol= %s\n", mycol );
}SQL Anywhere Studio 9.0.2
Copyright © 1989–2004 Sybase, Inc. Portions copyright © 2001–2004 iAnywhere Solutions, Inc. All rights reserved.