D
D
Dmitry Panchuk2016-09-27 18:41:06
PostgreSQL
Dmitry Panchuk, 2016-09-27 18:41:06

How to display result of Postgresql function in QSqlTableModel?

there is a function in the PostgreSQl database find( int )
it takes numeric values
​​returns tabular data
how to display this result in QSqlTableModel?
tried like this:
model->setTable("find(4161)");
model->select();
But no result

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel, 2016-09-28
@panchdima

Because setTable points to the name of a table, not a function.
functions are called via SELECT, you need to use
QSqlQueryModel

QSqlQueryModel *getFind = new QSqlQueryModel;
getFind ->setQuery(" SELECT find(4161)'");
if(getFind ->lastError().isValid()){
        qDebug() << getFind ->lastError();
}
model->setModel(getFind );
model->select();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question