[asterisk-dev] func_odbc.conf - Check Result Count

Philipp Kempgen philipp.kempgen at amooma.de
Fri Jun 5 08:41:35 CDT 2009


Muhammad Arfeen schrieb:

> I'm getting the query result from func_odbc.conf just fine.
> 
> but how would I get the result count of the query I ran, do I have to first
> count the result and the run the actual query ?
> 
> any to get the result count just like in PER "$#Result" or something like
> that.

Interesting question. There is ODBC_FETCH(${resultid}) but there is
no such thing as ODBC_COUNT_ROWS(${resultid}).

I guess you are supposed to fetch rows using
Set(HASH(row)=${ODBC_FETCH(${resultid})})
until "${HASH(row,id)}" == "" like so (untested):

Set(resultid=${ODBC_my_multirow_query()});
Set(num_rows=0);
while (1 == 1) {
    Set(HASH(row)=${ODBC_FETCH(${resultid})});
    Verbose(1,Row: "${HASH(row,id)}" "${HASH(row,foo)}" "${HASH(row,bar)}");
    if ("${HASH(row,id)}" == "") {
        break;
    }
    Set(num_rows=$[${num_rows} + 1]);
}
Verbose(1,Query returned ${num_rows} rows);


    Philipp Kempgen
-- 
AMOOMA GmbH - Bachstr. 126 - 56566 Neuwied  ->  http://www.amooma.de
Geschäftsführer: Stefan Wintermeyer, Handelsregister: Neuwied B14998
Asterisk: http://the-asterisk-book.com - http://das-asterisk-buch.de
Videos of the AMOOCON VoIP conference 2009 ->  http://www.amoocon.de
-- 



More information about the asterisk-dev mailing list