Discussion:
Can be used where conditions as parameter
(too old to reply)
Borland
2008-05-31 13:33:16 UTC
Permalink
Hi!

Is there any way to place a parameter in a SQLDataset CommandText which
contain a where condition:?

e.g.

select *
from table t
where t.field='xx'
and :parameter;

The value of the parameter ' t.field <>''yy'' '
Bill Todd [TeamB]
2008-05-31 14:20:56 UTC
Permalink
Please change your posting name to something other than Borland. Others
might think you are a Borland employee.

SQL Parameters are not macro substitution. When a parameterized SQL
statement is executed the SQL statement is sent to the database server
without that parameter values. The server parses and compiles the
statement into executable form. Then the parameters are sent to the
server and assigned to the variables in the statement. Finally the
statement is executed. Therefore, parameters can only contain a single
value. A parameter cannot contain code, a column name, a table name or
the name of any other database object.
--
Bill Todd (TeamB)
Paul Hughes
2008-06-03 00:47:38 UTC
Permalink
Post by Borland
Hi!
Is there any way to place a parameter in a SQLDataset CommandText which
contain a where condition:?
e.g.
select *
from table t
where t.field='xx'
and :parameter;
The value of the parameter ' t.field <>''yy'' '
If I understand correctly; say you have FIELD_A and FIELD_B in your table.
You would do this:

SELECT * FROM TABLE T
WHERE (T.FIELD_A = 'xx') AND (T.FIELD_B <> :MY_PARAM)

Then before executing the query you would set MY_PARAM to the value:

SQLDataSet.ParamByName('MY_PARAM').AsString := 'yy';

Regards, Paul.

Loading...