Re: Re: Parameterized SQL
Posted in 2005
The problem with ? is that you need to know the exact number of parameters inside the in.
I think is better to construct a string with all the sql (including the "in" with a separated coma list of chars).
Then execute this sql-tring through ODBC.
J.
-----Original Message-----
From: "Andrew Hamm" <ahamm@mail.com>
To: informix-list@iiug.org
Date: Wed, 23 Feb 2005 13:46:22 +1100
Subject: Re: Parameterized SQL "WHERE IN" clause?
William Fields wrote:
> Hello,
>
> I'm trying to come up with a way to pass a variable from Visual
> FoxPro to Informix via the current ODBC driver that looks something
> like this:
>
> SELECT * FROM MyTable WHERE MyField IN (?MyListOfValues)>
> ?MyListOfValues is a variable holding my list I want to filter on.
> Like: 'a', 'b', 'c', 'd', 'e'.
I don't know FoxPro, so I can only assume what sort of variable you are
using to store the 'a','b','c' part. Is it a string? I'll assume so.
When it binds MyListOfValues during execution of the statement, it will
probably make it look like this:
... WHERE MyField IN ("'a', 'b', 'c', 'd', 'e'")
in other words, one specific string complete with letters, commas, spaces
and quotes.
No dynamic SQL binding system I've ever seen does what you are asking for.
You might be able to exploit Informix's ROW types IF you can bind an array
to a ? but I doubt it, especially through ODBC.
On the bright side, these sorts of cases are precisely why it's acceptable
to prepare and re-prepare a statement on the fly. Manually build the
string and submit that without the use of ?
Jean Sagi
jeansagi@myrealbox.com
jeansagi@yahoo.com
sending to informix-list