A
A
Alexander Avtomonov2014-07-02 14:38:19
PostgreSQL
Alexander Avtomonov, 2014-07-02 14:38:19

Problem with prepared statements in PostgreSQL. How to fix?

There is a request:

INSERT INTO
              "control-question"
              (control_id,question_id)
            VALUES
              (:control_id0,:question_id0),(:control_id1,:question_id1)
            EXCEPT
              (SELECT
                 control_id,question_id
               FROM
                 "control-question")
             RETURNING
               question_id

And the data set control_id0=28, question_id0=8, control_id1=28, question_id1=9.
The control-question table contains only the 2 fields above, both are key.
The request does not want to be executed, despite the fact that the request with inline parameters is successfully executed, i.e.
INSERT INTO
             "control-question"
              (control_id,question_id)
            VALUES
              (28,8),(28,9)
            EXCEPT
              (SELECT
                 control_id,question_id
               FROM
                 "control-question")
             RETURNING
               question_id

runs successfully.
Please tell me how to fix the problem.
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alex Kheben, 2014-07-02
@zBit

What error does the DBMS return?
If you get at least the error code, you can guess what the problem is.
www.postgresql.org/docs/9.3/static/errcodes-append...

Y
yttrium, 2014-07-02
@yttrium

How is the expression actually handled?
The documentation states a different approach for this, and variable naming is different

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question