问题
i'm building app with delphi rio 10.3 with firedac sqlite3
pragma function not working with 'SELECT COMMAND' AS I Try Below:
procedure Tamdf.Button31Click(Sender:TObject);
begin
MyFDQuery.Open('SELECT name FROM PRAGMA_table_info("DOCM")');
ShowMessage(MyFDQuery.Fields[0].AsString);
end;
i receive ERROR message :"ERROR: no such table column: PRAGMA_table_info.name" what i did wrong ?
回答1:
With FireDAC you can use workaround with create temp table "table_info":
MyFDQuery.Open(
'DROP TABLE IF EXISTS table_info;' +
'CREATE TEMPORARY TABLE table_info AS SELECT * FROM pragma_table_info("DOCM");' +
'SELECT name FROM table_info');
Edit
My environment: Delphi 10.3.2 Rio, Win32, default SQLite 3.28.0 statically linked. No special settings.
Connection - TFDConnection
with only:
FDConnection1.Params.DriverID := 'SQLite';
FDConnection1.Params.Database := 'D:\TMP\TEST.db';
回答2:
The following code works fine for me on a Sqlite database containing the table `MyTable'. I'm not sure the SQL you are using is correct for use in FireDAC
procedure TForm3.Button1Click(Sender: TObject);
begin
if FDQuery1.Active then
FDQuery1.Close;
FDQuery1.Open('PRAGMA Table_Info(''MyTable'')');
end;
It returns
cid name
0 ID
1 NAME
If nothing else, you could use FireDAC's LocalSQL to extract the Name
from the returned result set.
I'll see if I can get SELECT working with the PRAGMA query ...
This query works fine in FireFox's Sqlite Manager add-in
select * from PRAGMA_table_info('mytable')
but returns the error
no such table: PRAGMA_Table_Info'.
when executed by FDQuery1.
来源:https://stackoverflow.com/questions/58661727/firedac-sqlite-no-such-table-column-pragma-table-info