Board index » delphi » 'and [fldname] in :param' ??? as string set????

'and [fldname] in :param' ??? as string set????


2003-10-11 05:30:52 AM
delphi240
Hey all:
I am using TQuery against ms sql server... when I hard code the query, last
line as
'and fldname in ('a','b')'
it works great...
however... when I use
and fldname in :jrn
and code
qry.ParamByName('jrn').AsString := '(''a'',''b'')';
it {*word*88}s and tells me that the buffer isn't big enough for return set and
will truncate and then eat my first born...
showing cwb0111...
any ideas how I might do this?
many thanx
b
 
 

Re:'and [fldname] in :param' ??? as string set????

Build your last SQL line dynamically in Delphi. Don't use parameters. You
could write a function that takes a TStringList as a parameter and returns
your string, e.g.: '(''a'',''b'')' . That way the number of items wouldn't
be hard-coded.
--
Alain Quesnel
XXXX@XXXXX.COM
www.logiquel.com
"Betsy" <XXXX@XXXXX.COM>writes
Quote
Hey all:

I am using TQuery against ms sql server... when I hard code the query,
last
line as
'and fldname in ('a','b')'
it works great...
however... when I use
and fldname in :jrn
and code
qry.ParamByName('jrn').AsString := '(''a'',''b'')';
it {*word*88}s and tells me that the buffer isn't big enough for return set and
will truncate and then eat my first born...
showing cwb0111...

any ideas how I might do this?

many thanx
b


 

Re:'and [fldname] in :param' ??? as string set????

Betsy writes:
Quote

I am using TQuery against ms sql server... when I hard code the
query, last line as
'and fldname in ('a','b')'
it works great...
however... when I use
and fldname in :jrn
and code
qry.ParamByName('jrn').AsString := '(''a'',''b'')';
it {*word*88}s and tells me that the buffer isn't big enough for return
set and will truncate and then eat my first born...
showing cwb0111...
This is a common problem for the IN operator for most (maybe all) SQL
databases - parameters cannot be handled. Continue to use parameters for
other things, but for IN, format the list of values manually.
--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: www.logicfundamentals.com/RADBooks.html
"It is error alone which needs the support of government. Truth can
stand by itself." - Thomas Jefferson
 

Re:'and [fldname] in :param' ??? as string set????

thanx guys... worked great!
"Betsy" <XXXX@XXXXX.COM>writes
Quote
Hey all:

I am using TQuery against ms sql server... when I hard code the query,
last
line as
'and fldname in ('a','b')'
it works great...
however... when I use
and fldname in :jrn
and code
qry.ParamByName('jrn').AsString := '(''a'',''b'')';
it {*word*88}s and tells me that the buffer isn't big enough for return set and
will truncate and then eat my first born...
showing cwb0111...

any ideas how I might do this?

many thanx
b