Q: How can I find out if rows are selected by a BEGIN-SELECT paragraph? Can I use the SQR variable #sql-count?

A: #sql-count indicates the number of rows affected by a DML statement (insert, update, or delete). It cannot be used for a BEGIN-SELECT paragraph. Here are two techniques to determine if data was selected.

---------------------------- Example code begins here -------------------------
begin-report
 do main1
 do main2
end-report

begin-procedure main1
move 0 to #count   ! This is optional unless main1 is called more than once
begin-select
column1
column2
column3
 add 1 to #count
from table1
end-select
if #count > 0
 show 'Number of rows selected was ' #count edit 999
else
 show 'No rows selected'
end-if
end-procedure main1

begin-procedure main2
begin-select
'true' &true
column1
column2
column3
from table1
end-select
if &true = 'true'
 show 'Selected at least one row'
else
 show 'No rows selected'
end-if
end-procedure

---------------------------- Example code ends here ---------------------------