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()
{
db.setDatabaseName("e193");
db.setHostName("localhost");
if (value.typeName() == "PGconn*")
{
PGconn *handle = *static_cast<PGconn **>(value.data());
if (handle != 0)
{}
}
return true;
}
#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;
}
To copy to clipboard, switch view to plain text mode
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");
db.driver()->subscribeToNotification("LISTEN notify");
To copy to clipboard, switch view to plain text mode
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.
Bookmarks