From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Igor Korot <ikorot01(at)gmail(dot)com> |
Cc: | "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Error on query execution |
Date: | 2025-03-06 17:00:16 |
Message-ID: | 702923.1741280416@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Igor Korot <ikorot01(at)gmail(dot)com> writes:
> On Tue, Mar 4, 2025 at 8:37 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> ... but given that you didn't specify any data type, I think the
>> parser will fall back to assuming that $1 is the same type as
>> "abf_type", whatever that is. Passing data in binary is not at all
>> forgiving about getting the data type right.
> Changing the line above to read:
> res = PQexecParams( m_db, "SELECT * FROM abcatfmt WHERE abf_type =
> $1::smallint", 1, nullptr, paramValues, paramLengths, paramFormats, 1
> );
That just makes it explicit that the query is expecting an int16.
You're still passing an int32. You need to either change the
parameter setup code to pass an int16, or make the query look
more like
res = PQexecParams( m_db, "SELECT * FROM abcatfmt WHERE abf_type =
$1::integer", 1, nullptr, paramValues, paramLengths, paramFormats, 1);
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | mark bradley | 2025-03-06 18:11:15 | Re: Duplicate Key Values |
Previous Message | Igor Korot | 2025-03-06 16:34:02 | Re: Error on query execution |