Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Getting error 42601 when running procedure in PostgreSQL

Getting error 42601 when running procedure in PostgreSQL

Scheduled Pinned Locked Moved Solved General and Desktop
sql
1 Posts 1 Posters 1.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    OpenGL
    wrote on 31 Oct 2020, 20:04 last edited by OpenGL 11 Jan 2020, 06:59
    #1

    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-it

    I'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 fail

    QSqlQuery 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.

    1 Reply Last reply
    0

    1/1

    31 Oct 2020, 20:04

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved