Back

PowerBuilder - Source Code - Getting the number of rows in a Table Dynamically


This function was originally written by one of my coworkers a long time ago.  It may not be particularly useful, but it is a good example of how to do Dynamic SQL - Format 3.

In this case, the function was written on the n_tr transaction object.

Function : of_get_count (String as_table)

long ll_count

string ls_select_statement

ls_select_statement = 'SELECT COUNT(*) INTO :ll_count FROM ' + as_table
DECLARE count DYNAMIC CURSOR for SQLCA;
PREPARE SQLSA FROM :ls_select_statement USING SQLCA;
OPEN DYNAMIC count;
FETCH count INTO :ll_count;
CLOSE count;

Return  ll_count


Back