Programming Guide |
Contains a count of the number of rows either fetched to Panther or affected by the previous statement
The use of this variable is dependent on the database engine. On all engines,
@dmrowcount
is set to the number of rows fetched to Panther variables in aSELECT
statement orCONTINUE
command. On some engines, it can also reflect the number of rows affected by anINSERT
,UPDATE
, andDELETE
statement.
@dmrowcount
is set to 0 before each newDBMS
command is executed. You must copy its value to another location if you want to use the value after subsequent commands.If the command fetches rows, Panther updates
@dmrowcount
writing the number of rows fetched to Panther variables. Most SQL syntaxes provide an aggregate functionCOUNT
to count the number of values in a column or the number of rows in a select set. The value of@dmrowcount
is not the number of rows in a select set; rather, it is the number of rows returned to Panther variables. Therefore if a select set has 14 rows in total, and its target Panther variables are arrays, each with ten occurrences,@dmrowcount
is 10 after theSELECT
is executed, and 4 afterCONTINUE
is executed. IfCONTINUE
is executed a second time,@dmrowcount
would equal 0.The value of
@dmrowcount
is either less than or equal to the maximum number of rows that can be written to the target Panther destinations; the maximum number of rows is the number of occurrences in a destination variable. If the value in@dmrowcount
is less than the maximum number of occurrences, then the entire select set is written to the target variables and no further processing is needed. If@dmrowcount
equals the maximum number of occurrences, then theSELECT
might fetch more rows than can fit in the variables. To display the rest of the select set, the application must executeCONTINUE
until@dmrowcount
is less than the maximum number of occurrences (or equals 0) or until@dmretcode
receives theDM_NO_MORE_ROWS
code.For information on whether the variable can be used to obtain the number of rows affected by an
INSERT
,UPDATE
, orDELETE
statement, refer to the Database Drivers for the specified engine.If you are using the transaction manager, call
sm_tm_inquire
(TM_OCC_COUNT
) to find the number of rows fetched in the current server view. Since a transaction command can consist of more than oneDBMS
command,@dmrowcount
might have already been overwritten.
proc get_selection
DBMS QUERY SELECT * FROM titles WHERE genre_code=:+type
call check_count
returnproc check_count
# If rows are returned but not the NO_MORE_ROWS code,
# let the user know there are rows pending.
if (@dmrowcount > 0) && \
(@dmretcode != DM_NO_MORE_ROWS)
msg setbkstat "Press %KPF1 to see more."
else
msg setbkstat "All rows returned."
returnproc get_more
# This function is called by pressing PF1.
# It retrieves the next set of rows.
DBMS CONTINUE
call check_count
return