PDA

View Full Version : QSqlQuery identify error type



matteo.ceruti
19th March 2012, 16:35
I'm using postgresql 9.1.
When I exec a QSqlQuery

qsqlQuery.exec("INSERT...

and there is an error, for example
"ERROR: duplicate key value violates unique constraint "usertable_name_key"
DETAIL: Key (name)=(2) already exists.
QPSQL: Unable to create query"

the error number return is -1? Is it possible to identify the different error type?
Thanks
Teo

majorwoody
19th March 2012, 20:10
I'm using postgresql 9.1.
the error number return is -1? Is it possible to identify the different error type?


QSqlQuery.lastError() returns a QSqlError which should give you all error information.

ChrisW67
20th March 2012, 00:26
You need more information than the rather extensive message you already have?