realbasic and recordset question

huck

Registered
How do I pull the value of a recordset. For example:

rc = db.recordset.sqlselect ("Select max(id) from table")

how do i return the value of that query, where "id" is the primary key field, and use the number for other puruposes (ie calculations)?
 
I ain't familiar with realbasic, but the regular procedure is as follows (applies to almost any SQL class I know):

1) Create a statement

This is what you do by executing the SELECT. It calls the database and prepares a result set.

2) - optional - Use the result set to query the column properties. For example, the recordset class should have a method to query the data type of each column.

3) Repeatedly fetch the data rows

Normally, you use a method called Fetch or similar which obtains the next row of data. This is a required step in order to retrieve any data, even if - as in your case - there is only one row containing one column.

4) After having fetched a row, the class should provide methods to retrieve the column data from that row. Such a method could be called Result or Column or something like that.

5) Having processed all data of a row, you typically fetch the next row. If there is no more data this should return a status code.

Hope this helps :)
 
Back
Top