Sergei Kuchin - 2014-01-12

otl_stream has a built-in function get_rpc():

code example

otl_stream i(50, // buffer size
"select * from test_tab where f1>=:f11<int> and f1<=:f12<int>*2",
// SELECT statement
db // connect object
);
// create select stream

int f1;
char f2[31];

i<<8<<8; // assigning :f11 = 8, :f12 = 8
// SELECT automatically executes when all input variables are
// assigned. First portion of output rows is fetched to the buffer

while(!i.eof()){ // while not end-of-data
i>>f1>>f2;
cout<<"f1="<<f1<<", f2="<<f2<<", rcp="<<i.get_rpc()<<endl;
}

output

f1=8, f2=Name8, rcp=1
f1=9, f2=Name9, rcp=2
f1=10, f2=Name10, rcp=3
f1=11, f2=Name11, rcp=4
f1=12, f2=Name12, rcp=5
f1=13, f2=Name13, rcp=6
f1=14, f2=Name14, rcp=7
f1=15, f2=Name15, rcp=8
f1=16, f2=Name16, rcp=9

Note that get_rpc() shows the row processed count, so in the context of a SELECT statement it means rows fetched count. If you need a total row count of a SELECT statement before doing any fetching, you'll have to run select count(*)... The underlying DB API (SNAC/ODBC) doesn't have any means to get the total row count without going through the fetch sequence of a SELECT statement.

Cheers,
Sergei