Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 5

Qt-interest Archive, February 2007
mysql and stored procedures


Message 1 in thread

Am having problems with using mysql5 and stored prodecures. It seems that
calling a procedure "kills" or "locks" the connection and am perplexed. Can
anyone offer some help.

   // Open connection to database and this works..
    bool ok = db.open();
    if(ok){
        qDebug() << "Connected";
    }else{
        qDebug() << "Connection failed";
    }

    qDebug() << "-------First Query - Which outputs ok";
    QSqlQuery query;
    query.exec("select word_id, w_long from sms_dict");
    while( query.next() ){
        qDebug() << query.value(1);
    }

    qDebug() << "-------Stored Procedure = Which outputs ok";
    QSqlQuery query_sp = db.exec("call test()");
    //query_sp.exec("call test()");
    while( query_sp.next() ){
        qDebug() << query_sp.value(1);
    }

    // This next query does not execute properly
    qDebug() << "-------Another Query ";
    QSqlQuery query2;
    query2.exec("select word_id, w_long from sms_dict");
    qDebug() << "This line is output ";
    // this while()  never seems to get executed ?
    while( query2.next() ){
        qDebug() << query2.value(1);
    }

    qDebug() << "This line is output and application continues, however
database is dead";