Page 1 of 1

ExecSQL parameter placeholder

Posted: Wed 24 Jun 2015 12:26
by pgsellmann
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.

Re: ExecSQL parameter placeholder

Posted: Thu 25 Jun 2015 09:45
by ViktorV
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.