1

I already downloaded the latest SQLite.dll from SQLite Download Page and try to load it using TFDPhysDriverLink.VendorLib

But when I run the app, which contains the following code:

procedure TForm1.FormCreate(Sender: TObject);
begin
  FDConnection1.Close;
  FDPhysSQLiteDriverLink1.Release;
  FDPhysSQLiteDriverLink1.VendorLib:= 'Path\SQLite3.dll';
  FDQuery1.Open('SELECT *, ROW_NUMBER() OVER() Col FROM TableName');
end;

It throws:

[FireDAC][Phys][SQLite] ERROR: near "(": syntax error

Which means that the window function ROW_NUMBER() is not recognized.

  • What I'm doing wrong?
  • How can I force FireDAC to use the latest SQLite.dll?
21
  • Did you check the documentation to see if SQLite supports that syntax at all? And if it does, I believe that it's OVER() that is causing the issue. Commented Oct 13, 2020 at 14:17
  • 2
    SELECT *, ROW_NUMBER() OVER() Col FROM TableName is not valid SQL for sure. Commented Oct 13, 2020 at 15:27
  • How about SELECT *, ROW_NUMBER() OVER (ORDER BY Col) FROM TableName? See Built-in Window Functions. Commented Oct 13, 2020 at 16:33
  • Nope, SELECT *, ROW_NUMBER() OVER() Col FROM TableName is valid SQL @ArnaudBouchez, and even SELECT *, ROW_NUMBER() OVER( ORDER BY ColumnName) Col FROM TableName is not working Commented Oct 13, 2020 at 17:06
  • 1
    It seem you have to recompile FireDAC, which is really lame. See answer to Firedac not recognizing new ALTER feature in sqlite3. Commented Oct 13, 2020 at 19:04

2 Answers 2

1

SQLite do not support ROW_NUMBER. Look at the answers for this question, you'll probably find something to replace ROW_NUMBER.

Sign up to request clarification or add additional context in comments.

2 Comments

That statement is wrong. SQLite supports ROW_NUMBER since version 3.25.0. This is also what the most voted answer to the question you linked to says.
0

If you get this error, then the SQlite3.dll was loaded just fine.

Just use the RowID field, which is always existing for any standard SQLite3 table - unless you explicitly created them with CREATE TABLE WITHOUT ROWID statement.

So I would just write:

 FDQuery1.Open('SELECT *, RowID FROM TableName');

Note that if there is an explicit INTEGER PRIMARY KEY column in your table, it will in fact map the internal RowID column. Check the SQLite3 documentation for how this works.

1 Comment

No, I don't want to use the ROWID, instead I want to use the window function. ROW_NUMBER() OVER() is just an example of window functions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.