Page 1 of 1

Original BDE message is: near Limit: syntax error

Posted: Wed 29 Feb 2012 15:07
by Lepsik
What I'm doing wrong?

Code: Select all

    Limits.Open;
    Limits.First;
    for Iter := 1 to LimitParamCount do
    begin
      Limit := GetDefaultLimit(Iter, AModel);
      if Limit > 0 then
      begin
        Limits.Append;
        LimitsModel.Value := AModel;
        LimitsParamID.Value := Iter;
        LimitsLimit.Value := Limit;
        Limits.Post;    // here I having error message !!!
      end;
in DBonitor:

Code: Select all

INSERT INTO LimitValues
  (Model, ParamID, Limit)
VALUES
(?, ?, ?)

Why DBMonitor does not allow to copy the text of event?

Posted: Wed 29 Feb 2012 15:36
by Lepsik
it looks like SQLlite provider does not suport autoinc filed:

Code: Select all

CREATE TABLE "LIMITVALUES"("PKey" INTEGER AUTOINC, "Model" INTEGER, "ParamID" INTEGER, "Limit" INTEGER, PRIMARY KEY ("PKey"));
I connected to MSSQL and this code works fine:

Code: Select all

declare @p6 int
set @p6=216
exec sp_executesql N'INSERT INTO LimitValues
  (Limit, ParamID, Model)
VALUES
  (@P1, @P2, @P3)
SET @P4 = SCOPE_IDENTITY()',N'@P1 int,@P2 int,@P3 int,@P4 int OUTPUT',2147483647,13,0,@p6 output
select @p6 

Posted: Wed 29 Feb 2012 17:09
by Lepsik
I found the problem:

When SQLlite does insert it has to wrap field names and table name to required for each provider's specific. For SQLLite: doubel quites and for MSSQL squer brakets

Code: Select all

insert into limitvalues (Model, ParamID, 'limit') values (1, 2, 3)

Posted: Thu 01 Mar 2012 11:18
by AlexP
Hello,

If you use keywords as table fields, like FROM, LIMIT, etc., for correct formatting of the queries INSERT, UPDATE, DELETE, REFRESH, you should either quote these fields explicitly or turn on the QuoteNames option

Code: Select all

  UniQuery1.Options.QuoteNames := true;