BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Parameters in WHERE/IN clause value list?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder Databases (InterBase Express)
View previous topic :: View next topic  
Author Message
TerryC
Guest





PostPosted: Mon Feb 27, 2006 6:03 pm    Post subject: Parameters in WHERE/IN clause value list? Reply with quote



I'm trying to use a parameterized query where the parameters are
in place of a comma-separated list of integers used in a
WHERE/ IN statement.

The problem is, I get an error:

"SQL error code = -303"
"arithmetic exception, numeric overflow, or string truncation"

If, however, I recreate the SQL by substituting the list of
numbers directly into the text, it works correctly.

Is it possible to correctly use parameters for a list of integer
values in a WHERE/IN clause?

Thanks,
Terry
Back to top
Wayne Niddery [TeamB]
Guest





PostPosted: Mon Feb 27, 2006 8:03 pm    Post subject: Re: Parameters in WHERE/IN clause value list? Reply with quote



TerryC wrote:
Quote:

Is it possible to correctly use parameters for a list of integer
values in a WHERE/IN clause?

Not a *variable length* list.

If you know you will always pass, say, 3 values, then it can work:

select * from table where field in (:a, :b, :c)

and you assign each of the 3 parameters.

But you cannot do:

select * from table where field in (:list)

and assign that one parameter something like '1001, 1002, 1003'. Interbase
will see that as a single parameter value and try to find rows that have
that entire string as a field value.

You can look at http://cc.borland.com/Item.aspx?id=15065 to see one possible
solution to this, but it has limitations. Be sure to read the posted
comments.

--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: http://www.logicfundamentals.com/RADBooks.html
SpaceShipOne; GovernmentZero
Back to top
TerryC
Guest





PostPosted: Mon Feb 27, 2006 9:03 pm    Post subject: Re: Parameters in WHERE/IN clause value list? Reply with quote



Quote:
Is it possible to correctly use parameters for a list of
integer values in a WHERE/IN clause?

Not a *variable length* list.

If you know you will always pass, say, 3 values, then it can
work:

select * from table where field in (:a, :b, :c)

and you assign each of the 3 parameters.

But you cannot do:

select * from table where field in (:list)

and assign that one parameter something like '1001, 1002,
1003'. Interbase will see that as a single parameter value and
try to find rows that have that entire string as a field value.

You can look at http://cc.borland.com/Item.aspx?id=15065 to see
one possible solution to this, but it has limitations. Be sure
to read the posted comments.

Thanks for this, Wayne. I'll look it over closely. I think
this approach MIGHT work for me.

-Terry
Back to top
Quinn Wildman
Guest





PostPosted: Wed Mar 08, 2006 7:03 pm    Post subject: Re: Parameters in WHERE/IN clause value list? Reply with quote

Another possible solution would be to do an inner join with a temporary
that has the IN values.

Wayne Niddery [TeamB] wrote:
Quote:
TerryC wrote:
Is it possible to correctly use parameters for a list of integer
values in a WHERE/IN clause?

Not a *variable length* list.

If you know you will always pass, say, 3 values, then it can work:

select * from table where field in (:a, :b, :c)

and you assign each of the 3 parameters.

But you cannot do:

select * from table where field in (:list)

and assign that one parameter something like '1001, 1002, 1003'. Interbase
will see that as a single parameter value and try to find rows that have
that entire string as a field value.

You can look at http://cc.borland.com/Item.aspx?id=15065 to see one possible
solution to this, but it has limitations. Be sure to read the posted
comments.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder Databases (InterBase Express) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.