[fpc-pascal] Sqldb - How to pass an array of values as a param to be used with SQL IN operator?
tony.caduto at gmail.com
Sun Apr 10 21:29:02 CEST 2016
What about using a stored procedure to do it ? You could pass the list for
the in as a string and handle it in the stored procedure. Of course that's
no help if using sqlite or other that does not support stored procedures.
On Apr 10, 2016 1:39 PM, "Stephen Chrzanowski" <pontiac76 at gmail.com> wrote:
The problem with that Tony is that the the bind might make :myparam a
string, so you'll be doing a 1-integer to 1-string comparison, which won't
give you any results. Essentially you'll be asking for a list of results
whos field is equal to "1,2,3,4", not a list of results in which the field
in question contains the numbers 1, or 2, or 3, or 4.
Due to the nature of the bind mechanism, you won't be able to do it this
way. The only way you'll be able to do that is with your program doing
string substitution instead of doing the bind. Since you're dealing with
integers only, you'll just need to make sure that every entry you're
substituting for is actually an integer.
On Sun, Apr 10, 2016 at 10:01 AM, Tony Caduto <tony.caduto at gmail.com> wrote:
> Did you try putting quotes around the param ID in the sql query?
> I am guessing it's the commas that are the problem.
> Sqlite will accept double qoutes as will MySQL postgres will not though.
> On Apr 10, 2016 7:40 AM, "leledumbo" <leledumbo_cool at yahoo.co.id> wrote:
>> > But until now i havent figured a way to pass an array of values (mostly
>> integers) to be used with IN operators.
>> That, unfortunately, is not possible. It's a DBMS limitation,
>> values are actually passed as is to DBMS. So there's nothing you can do
>> unless you can convince DBMS maintainer to implement it.
>> > Is there a way to accomplish this?
>> No other way than direct formatting for now.
>> View this message in context:
>> Sent from the Free Pascal - General mailing list archive at Nabble.com.
>> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
fpc-pascal maillist - fpc-pascal at lists.freepascal.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the fpc-pascal