Skip site navigation (1) Skip section navigation (2)

Re: BUG #3951: SELECT ... WHERE Param = ? does not work if Param is of type bytea

From: Vincent D'Haene <vincent_dhaene(at)hotmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Gevik Babakhani <pgdev(at)xs4all(dot)nl>, <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #3951: SELECT ... WHERE Param = ? does not work if Param is of type bytea
Date: 2008-02-21 20:53:42
Message-ID: BAY124-W3640B67940655434EBE19AFE1C0@phx.gbl (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
Hi Tom,

Tx for you really clear answer, it helped a lot.

I just found the problem and it could indeed be seen as a bug in my code, although that very same piece of code works without any problem on MSSQL 2K, MSSQL 2K5, MSSQL Express, Oracle 9i, Oracle 10, MySQL 5.0 and MySQL 5.1.

The problem was the following:

When specifying the following statement:

  SQLBindParameter(hStmt, 1, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_BINARY, 16, 0, ValuePtr, 16, &IndPtr)

and the column bound is of binary type (BYTEA, IMAGE, BLOB, ...), the IndPtr must contain the length of the data passed in ValuePtr.

In my code I had it set to 0 (because I already specified the length of the field in the DataLen parameter), which doesn't seem to work for postgresql.

Regards and have a nice day, Vincent

> To: vincent_dhaene(at)hotmail(dot)com
> CC: pgdev(at)xs4all(dot)nl; pgsql-bugs(at)postgresql(dot)org
> Subject: Re: [BUGS] BUG #3951: SELECT ... WHERE Param = ? does not work if Param is of type bytea 
> Date: Thu, 21 Feb 2008 13:30:02 -0500
> From: tgl(at)sss(dot)pgh(dot)pa(dot)us
> "Vincent D'Haene" <vincent_dhaene(at)hotmail(dot)com> writes:
> > My problem is that it seems that in postgresql you can't use a parameter bound to BYTEA data in the WHERE clause of the SQL statement.
> The above claim is nonsense.
> > So in my case: "SELECT x FROM T WHERE BinData = ?" does not work (return code -1) if the parameter bound to the ? is of type BYTEA.
> I'm guessing that you've got an ODBC problem.  That could be a bug in
> your code, or less likely a bug in the ODBC driver you're using.
> Since you haven't specified which driver or which version of the driver
> you're using, nor provided a test case to run, it's difficult for anyone
> else to investigate it.
> 			regards, tom lane

Express yourself instantly with MSN Messenger! Download today it's FREE!

In response to

pgsql-bugs by date

Next:From: Simon RiggsDate: 2008-02-21 21:18:32
Subject: Re: Incomplete docs for restore_command for hot standby
Previous:From: Matthias MohrDate: 2008-02-21 20:27:20
Subject: 8.3 problems with sspi authentication

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group