Getting error 42601 when running procedure in PostgreSQL
Solved
General and Desktop
-
I've deleted this and created a new topic with a minimal example included.
https://forum.qt.io/topic/120460/minimal-sql-program-that-fails-what-is-wrong-with-itI've created a program that connects to a PostgreSQL database and now I'm trying to call a procedure (that works, I've tested it directly in the database)
but this failQSqlQuery query(m_db); query.prepare(QString("call add_new_task(?,?,?,?,?, ?, ?)")); query.bindValue(0, task.get_c()); query.bindValue(1, task.get_d()); query.bindValue(2, task.get_p()); query.bindValue(3, task.get_e()); query.bindValue(4, task.get_after()); query.bindValue(5, task.get_before()); query.bindValue(6, 0, QSql::InOut); if (query.exec()) { ... this is not run ... } else { ... this is run ... }
and it fails with the error
QSqlError("42601", "QPSQL: Unable to create query", "ERROR: syntax error at or near \"(\"\nLINE 1: EXECUTE ('C X', 'D X', 5, 8, '2020-10-31', ...\n ^\n(42601)")
In the postgresql logs I see
syntaxerror at or near "call" at character 25 PREPARE qpsqlpstmt_1 AS call add_new_task($1, $2, $3, $4, $5, $6, $7) ERROR: syntaxerror at or near "(" vid tecken 10 STATEMENT: EXECUTE ('Caption X', 'Description X', 5, 8, '2020-10-31', '2120-10-31', 0)
How can I find the error? Please help me, I'm stuck.