Subject Aw: RE: [firebird-support] with wrong sql i get no exception or firebird error
Author Harald Wolf
i'm aware of this SQLException class but its usesless if a no exception is thrown when the SQL statement is invalid.
This code does not trap anything:
 
            tr = IBPP::TransactionFactory(db);
            IBPP::Statement st = IBPP::StatementFactory(db, tr);
            db->Connect();
            tr->Start();
            st->Execute("blabla");  // a correct sql statement here works well.
            tr->Commit();
 
Sorry for posting here but ibpp mailinglist seems to be dead.
Any suggestions?
 
Gesendet: Donnerstag, 14. November 2019 um 15:53 Uhr
Von: "'Paul Beach' pbeach@... [firebird-support]" <firebird-support@yahoogroups.com>
An: firebird-support@yahoogroups.com
Betreff: RE: [firebird-support] with wrong sql i get no exception or firebird error
 


<<i use the ibpp.org c++ lib. How can i get the firebird sql error in my c++ code?

for example the ISQL line:
SQL> INSERT INTO LOG(WAS) VALUES ('blabla');
causes the error:
Statement failed, SQLSTATE = 23000
validation error for column "LOG"."ID", value "*** null ***"

if postet with the c++ code:
IBPP::Transaction _tr = IBPP::TransactionFactory(db);
IBPP::Statement st = IBPP::StatementFactory(db, _tr);
_tr->Start();
st->Prepare("INSERT INTO LOG(WAS) VALUES (?)");
st->Set(1, "blabla");
st->Execute();
_tr->Commit();

i get no error...nothing! No Record is created.
In other error cases i get an ibpp message with try catch IBPP::Exception& e
somethin like.

*** IBPP::LogicException ***
Context: Statement::Set[char*]
Message: The statement does not take parameters.

but never the real firebird error.

How can get this errors?>>

Probably by using
Class::SQLException

http://www.ibpp.org/reference/exceptions

Paul