ederbs
10th December 2007, 14:24
Hi Friends,
I am trying to create an event notifications from the database using PostgreSQL, but I am not understanding how to create this event.
The code connection:
#include <QSqlDatabase>
#include <QSqlDriver>
#include <QVariant>
extern "C" {
#include <postgresql/libpq-fe.h>
}
inline static bool PQ()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
db.setDatabaseName("e193");
db.setHostName("localhost");
QVariant value = db.driver()->handle();
if (value.typeName() == "PGconn*")
{
PGconn *handle = *static_cast<PGconn **>(value.data());
if (handle != 0)
{}
}
return true;
}
With the code above the connection is created without problems, as do more to trigger the event of the database?
When use:
db.driver()->subscribeToNotification("LISTEN notify");
Get the following error:
QPSQLDriver::subscribeToNotificationImplementation : database not open.
More connection was opened! Please, someone could help me?
Using Qt SnapShot -> Qt-4.4.0-snapshot-20071205
Thank you, edm.
I am trying to create an event notifications from the database using PostgreSQL, but I am not understanding how to create this event.
The code connection:
#include <QSqlDatabase>
#include <QSqlDriver>
#include <QVariant>
extern "C" {
#include <postgresql/libpq-fe.h>
}
inline static bool PQ()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
db.setDatabaseName("e193");
db.setHostName("localhost");
QVariant value = db.driver()->handle();
if (value.typeName() == "PGconn*")
{
PGconn *handle = *static_cast<PGconn **>(value.data());
if (handle != 0)
{}
}
return true;
}
With the code above the connection is created without problems, as do more to trigger the event of the database?
When use:
db.driver()->subscribeToNotification("LISTEN notify");
Get the following error:
QPSQLDriver::subscribeToNotificationImplementation : database not open.
More connection was opened! Please, someone could help me?
Using Qt SnapShot -> Qt-4.4.0-snapshot-20071205
Thank you, edm.