There are variables that are updated automatically by the system as a result ("output") of the database operation.
The followings are general System Variables in the database object:
Variable |
Description |
dbobj%tablelist |
Contains a list of table names available in the underlying database. Value initialised upon the first access of "database" command regardless of what operation and table it is on (if at all), and the value does not changed in the entire page run. |
dbobj%fieldlist |
Contains a list of field names available in the table specified in dbobj%table, or if it is not specified, the name of dbobj.
If you modify the value of dbobj%table, the next access to the "database" command will see dbobj%fieldlist updated with a new field list of the newly specified table.
Any successful data retrieval operation will update dbobj%fieldlist as well, even if it was via the SQL statement containing in the "query" parameter. |
dbobj%query |
Last query statement regardless of whether it was successful or not |
dbobj%queryaction |
Action of the last query statement (i.e. "select", "update", "insert" or "delete") regardless of whether it was successful or not |
The followings are general System Variables in system classes:
Variable |
Description |
dbobj%status or status%database |
Error code of the database operation, or 0 if successful |
dbobj%message or message%database |
Error message of the database operation, or blank if successful |
session%database:query |
Last successful query saved as persistent value that is kept through out the client session |
session%database:select |
Last successful select query saved as persistent value that is kept through out the client session |
session%database:update |
Last successful update query saved as persistent value that is kept through out the client session |
session%database:insert |
Last successful insert query saved as persistent value that is kept through out the client session |
session%database:delete |
Last successful delete query saved as persistent value that is kept through out the client session |
session%database:queryaction |
Action of last successful query saved as persistent value that is kept through out the client session |
A brief note on session%database, upon a successful database operation, the system will save dbobj%query into session%database:query, and dbobj%queryaction into session%database:queryaction, then save dbobj%query again into session%database:{dbobj%queryaction}.
These "session" variables also have a copy in session%{dbobj%name}, where {dbobj%name} is the unique name the system generates or you explicitly specify in the database operation.
There are some System Variables that are related to data retrieval only:
Variable |
Description |
dbobj%numrecs or any of these: dbobj%numrec dbobj%numrecords dbobj%numrecord dbobj%numrows dbobj%numrow |
Number of records in the record set retrieved in the last query, or 0 if it was unsuccessful or was not a data retrieval query. |
dbobj%thisrecord:field |
Contains the Field field in the record just retrieved. (If the record just retrieved is empty, for example, when retrieved beyond the last record in the record set, dbobj%thisrecord will not be updated (and will retain its last value). |
dbobj%lastrecord:field |
Contains the Field field in the record retrieved before the one just retrieved. If the record just retrieved is empty, for example, when retrieved beyond the last record in the record set, dbobj%lastrecord will not be updated (and will retain its last value). |
dbobj%datacount |
Contains the number of records read so far. |
dbobj%datacount:field |
Contains the number of last consecutive retrievals in which the data of Field field has not changed.
For example, if vehicle%thisrecord:make is "BMW" and vehicle%datacount:make is 3, then you can tell that the last two retrievals on "make" were also "BMW".
This is useful in detecting change of value (i.e. when dbobj%datacount:field is 1) to determine the end of a subtable.
If the record just retrieved is empty, for example, when retrieved beyond the last record in the record set, dbobj%lastrecord will not be updated (and will retain its last value). |
There are some variables that are related to data insertion only:
Variable |
Description |
dbobj%lastseq |
The last sequence number inserted into the table. It is an output from the "nextseq" action. If the value is negative (-1), that means the previous "nextseq" came up with an error.
Please note that not all database platform supports a retrieval of the last generated sequence number. Please see Database Action "nextseq". |
|