On 19 July 2013 08:47, Faik Uygur |SmartSoft <[email protected]> wrote:

>   Hello,
>
> I am using soci version 3.2.1 with Oracle backend. I am using prepared
> statements. If a single row selecting statement is called with
> stmt->execute(true); - select after select works but if a multiple row
> returning select statement is used and I use "stmt->execute(false) while
> (stmt->fetch()) ..."  the second run of execute-fetch cycle does not return
> any data. Am i missing something or is this a bug in Oracle backend. I
> looked for something like cursor reset, row reset if maybe needed but
> couldn't find anything related.
>

There is statement::clean_up(), but you should not need to call it, in most
cases.


>  Here is some code that would help to understand the problem:
>
> ---
>
> MyClass {
> ...
>     private:
>         shared_ptr<statement> _select;
> ...
> }
>
> void MyClass::setup() {
>     _select.reset(new statement((_session->prepare << "select "
>                                     "guid, status, lastupdated, "
>                                     "func_code, dst_host1, dst_port1 "
>                                     "from sys_cnn "
>                                     "where status = 1",
>                                     into(guid), into(status),
> into(lastupdated),
>                                     into(func_code), into(dst_host1),
> into(dst_port1)
>                                     )));
> }
>
> bool MyClass::load() {
>     _select->execute();
>     while (_select->fetch()) {
>             // use data returned from each fetch
>     }
>     return _session->got_data();
> }
>
>

So, AFAIU, your use case is basically equivalent to re-execution of
statement as below:

T c;
statement st = (sql.prepare << "select c from t", into(c));
for (int j = 0; j < 2; ++j) // mimic two calls to load()
{
    st.execute();
    while (st.fetch())
    {
        // use c
    }
}

This should work and it works for PostgreSQL backend.
I don't have access to Oracle at the moment.
I may be able to test it over the weekend or next week.

Best regards,
-- 
Mateusz  Loskot, http://mateusz.loskot.net
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
soci-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/soci-users

Reply via email to