Original BDE message is: near Limit: syntax error

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Lepsik
Posts: 12
Joined: Mon 27 Feb 2012 17:45
Contact:

Original BDE message is: near Limit: syntax error

Post by Lepsik » Wed 29 Feb 2012 15:07

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?

Lepsik
Posts: 12
Joined: Mon 27 Feb 2012 17:45
Contact:

Post by Lepsik » Wed 29 Feb 2012 15:36

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 

Lepsik
Posts: 12
Joined: Mon 27 Feb 2012 17:45
Contact:

Post by Lepsik » Wed 29 Feb 2012 17:09

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)

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Thu 01 Mar 2012 11:18

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;

Post Reply