0

Good morning.

I'm with a problem that I can't figure out. The situation is the following: I have a procedure that I call passing it a string, which is basically the name of a table. In this particular case it is "sys".

This procedure basically executes the following lines:

Query.Close ();
Query.ParamByName ('TABLE'). AsString: = Table;
Query.Open;

"Query" basically has this:

SELECT * FROM: TABLE;

Therefore you should run the following:

SELECT * FROM sys;

Truth?

Well, apparently I'm having a bug. Since when testing it and executing my procedure this happens:

[FireDAC] [Phys] [SQLite] ERROR: near ": TABLE:" syntax error.

** Does SQLite work differently with parameters? ** I can not find why it fails.

Julian
  • 43
  • 5
  • Parameters can only be used for values not any identifiers or SQL keywords. This is true of all SQL dialects. Also the `:` needs to be at the start of a parameter name. So `SELECT * FROM PEOPLE WHERE FIRSTNAME = :FNAME` has a parameter called `FNAME`. – Brian Dec 17 '21 at 16:28
  • Firedac does have macros which can be used for everything. They are evaluated and the SQL updated before it is sent to the database. – Brian Dec 17 '21 at 16:32

1 Answers1

0

Base of SQLite document and this link you can't pass table name as parameter:
[https://stackoverflow.com/questions/5870284/can-i-use-parameters-for-the-table-name-in-sqlite3][1]

Instead of that you can make your string of query by this manner(trick):

Query.sql[1]:='tablename'

Default query string my be like this:

select * form
//X (line 1 )
where ....
A.K.D.
  • 90
  • 9