Params Problem
Hi
it is easy to pass params to query but there is problem with (in) expression such as
select * from tbl a
where a.fld in :param1
if you called it by this script
q.params[0].value := (1,4,5,9,11);
you will get error
pleas help me...........................thanks
it is easy to pass params to query but there is problem with (in) expression such as
select * from tbl a
where a.fld in :param1
if you called it by this script
q.params[0].value := (1,4,5,9,11);
you will get error
pleas help me...........................thanks
Comments
var param1 string;
param1 := '(1,4,5,9,11)';
sql_msg= 'select * from tbl a where a.fld in ' + param1
then execute it!
I tried this code
var param1 string;
param1 := '(1,4,5,9,11)';
sql_msg= 'select * from tbl a where a.fld in ' + param1
and this
sql_msg= format('select * from tbl a where a.fld in %s ',<var1>)
its runnig good from report desiner but its not when you try to load report from delphi whith variables such as
frxrep1.variables := '(1,4,6)';
important note a.fld is integer field
frxrep1.variables := ''''+'(1,4,6)'+'''';
when i try to add extra quotes
frxrep1.variables := ''''+'(1,4,6)'+'''';
i eceived this error mssage
could not convert variant (string) into type (double)
"sql_msg= format('select * from tbl a where a.fld in %s ',<var1>)
its runnig good from report desiner"
the problem is usually in the code where we pass the value from delphi to the variable, delphi strips the '
here is a tip on how to find, it look at the hardcoded value (that works) in the variable and note how it appears, now go to delphi and where you load the report and set the variables value instead of calling showreport call design report when the designer comes up look at the variable and see what has been placed in the variables expression if it doesnt match what you would have hardcoded go back out to delphi and adjust delphi code, repeat untill you get it correct.
thank for value advice
yes i found the problem and fix it