A Table object is always located at one of the following positions:
If the Table object is positioned on a row, you can use one of a set of methods appropriate for the data type to retrieve or modify the value of the columns in that row.
The Table object provides a set of methods for retrieving column values. These methods take the column ID as the argument.
The following code fragment retrieves the value of the lname column, which is a character string.
ULValue val; char lname[ MAX_NAME_LEN ]; val = tbl->Get( UL_TEXT("lname") ); val.GetString( lname, MAX_NAME_LEN ); |
The following code retrieves the value of the cust_id column, which is an integer.
int id = tbl->Get( UL_TEXT("cust_id") ); |
In addition to the methods for retrieving values, there are methods for setting values. These methods take the column ID and the value as arguments.
For example, the following code sets the value of the lname column to Kaminski.
ULValue lname_col( UL_TEXT("fname") ); ULValue v_lname( UL_TEXT("Kaminski") ); tbl->Set( lname_col, v_lname ); |
By setting column values, you do not directly alter the data in the database. You can assign values to the properties, even if you are before the first row or after the last row of the table. Do not attempt to access data when the current row is undefined. For example, attempting to fetch the column value in the following example is incorrect:
// This code is incorrect tbl.BeforeFirst(); id = tbl.Get( cust_id ); |
The method you choose should match the data type you want to assign. UltraLite automatically casts database data types where they are compatible, so that you can use the GetString method to fetch an integer value into a string variable, and so on. See Converting data types explicitly.
Send feedback about this page via email or DocCommentXchange | Copyright © 2008, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.0 |