execute sql with parameters already replaced

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Ludek
Posts: 296
Joined: Thu 12 Oct 2006 09:34

execute sql with parameters already replaced

Post by Ludek » Tue 13 Oct 2015 07:35

Hi,
I have a query text, where the parameters have already been replace with question marks:

select ?, ?, ?

and I have also orderer list of the corresponding values in array of variant.

How do i execute such query?
I tried TMSConnection.ExecSQL, but this method expects named parameters in the sql text (:param1, :param2 etc.)

Thanks, Ludek.

ViktorV
Devart Team
Posts: 2299
Joined: Wed 30 Jul 2014 07:16

Re: execute sql with parameters already replaced

Post by ViktorV » Tue 13 Oct 2015 09:04

For successful execution of the specified query, you should modify it to the following:

Code: Select all

select :p1, :p2, :p3
SDAC generates parameters automatically, using the SQL query text.

Ludek
Posts: 296
Joined: Thu 12 Oct 2006 09:34

Re: execute sql with parameters already replaced

Post by Ludek » Tue 13 Oct 2015 11:40

... and sdac again parses all the params and changes it internally again back to ?, ?, ?...
I hoped, i could save this superfluous parsing and replacing using some low-level access, especially when the query contains 2000 parameters...

ViktorV
Devart Team
Posts: 2299
Joined: Wed 30 Jul 2014 07:16

Re: execute sql with parameters already replaced

Post by ViktorV » Tue 13 Oct 2015 12:39

When parsing a query, we replace not just all the :ParamName entries with ?, but also create an internal structure for using parameters. So you can't use a query, in which parameter names are replaced with ?.

Post Reply