ExecSQL parameter placeholder

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
pgsellmann
Posts: 1
Joined: Wed 24 Jun 2015 11:52

ExecSQL parameter placeholder

Post by pgsellmann » Wed 24 Jun 2015 12:26

I want to use the ExecSQL method with parameters. My SQL-statement looks similar to

Code: Select all

INSERT INTO `trend` (`stamp`, `charge`, `prognr`, `tprim`, `tsek`)
  VALUES (CURRENT_TIMESTAMP, '2', '1', '37.9', '-32.33');
but the numbers should be the parameters. so i prepare a variant array

Code: Select all

var
  pp: array of Variant;
begin
  SetLength(pp,4);
  pp[0] := 2;
  pp[1] := 1;
  pp[2] := 37.8;
  pp[3] := -32.16;
but cannot guess the correct VALUES-clause. Is it
  • VALUES (CURRENT_TIMESTAMP, ?, ?, ?, ?)
  • VALUES (CURRENT_TIMESTAMP, %, %, %, %)
The manual page at
https://www.devart.com/mydac/docs/?deva ... t[]%29.htm
doesnt specify this but only links to ExecSQLEx which uses named parameters.

ExecSQL uses an ordered param list and i expect the placeholders looking similar as in the Format-function.

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

Re: ExecSQL parameter placeholder

Post by ViktorV » Thu 25 Jun 2015 09:45

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

Code: Select all

INSERT INTO `trend` (`stamp`, `charge`, `prognr`, `tprim`, `tsek`) VALUES (CURRENT_TIMESTAMP, :p1, :p2, :p3, :p4);
MyDAC generates parameters automatically, using the SQL query text.

Post Reply