Page 1 of 1

fetch_by_id returns error(QSqlerror::type=4) when no data

PostPosted: Sun Apr 13, 2014 10:11 pm
by ledunkang
My code likes this
Code: Select all
daoError = qx::dao::fetch_by_id(ap);
        bCommit = !daoError.isValid();

        if(!bCommit)
            qDebug() << "==> DaoErr Type: " << daoError.type();

If data exists, the (oci) query executes succesfully, while it returns error if no data exists and assert failed.
I don't think that sucess query without data queried shoud be regard as an sql error. Or I missed anything?

Re: fetch_by_id returns error(QSqlerror::type=4) when no dat

PostPosted: Mon Apr 14, 2014 7:04 am
by qxorm
Hi,

You are trying to fetch an item by id, so you know the id and you expect that the id exists in your database.
If not exists, there is something wrong, this is why QSqlError returns an error.

If you want to test it before fetching, just use qx::dao::exist() function.

Re: fetch_by_id returns error(QSqlerror::type=4) when no dat

PostPosted: Mon Apr 14, 2014 2:07 pm
by ledunkang
Thanks, I'll try.