Good afternoon, I am starting in the world of Qt and the Firebird database. And we complete the driver installation process and perform the operations of inserting, updating and consulting in the database. When I started doing stored procedures and running them from Qt, it didn't work. We always fail, that everything was perfect, but the database does not work. I program on Linux using Qt 2.0.1 and Firebird 2.1. I create a simple stored procedure test that makes it paste into a table. It works by starting the console, but when trying to start fromQt it does not work and does not give me any errors. SQL code:
SET TERM ^ ;CREATE PROCEDURE AGREEGAR_UNO AS BEGIN insert into JUEGO(CODIGO,ESCRUTINIO,ESTADO,FECHA,HORAINICIO) values (next value for GNECODIGOJUEGO,'111,123,154,169,178','Hi', current_date, current_time);END^SET TERM ; ^
GRANT EXECUTE ON PROCEDURE AGREEGAR_UNO TO SYSDBA;
The following code will be used to connect to firebird from Qt
bool VentanaPrueba::conectar()
{
this->db= QSqlDatabase::addDatabase("QIBASE","Data");
this->db.setDatabaseName("./BD/Data.fdb");
this->db.setPassword("password");
this->db.setUserName("SYSDBA");
if(!db.open())
{
return false;
}
else
return true;
}
And this is the code that is responsible for calling the procedure
void VentanaPrueba::procedimiento()
{
if (!this->db.isOpen()) this->conectar();
if(this->db.isOpen())
{ QSqlQuery procedimiento = QSqlQuery::QSqlQuery(this->db);
bool bandera = procedimiento.prepare("EXECUTE PROCEDURE AGREEGAR_UNO");
QString err = procedimiento.lastError().text();
bool respuesta= procedimiento.exec();
if(!respuesta)
{
this->db.close();
}else
{
procedimiento.finish();
this->db.commit();
this->db.close();
}
}else{
}
}
Many thanks for your help.