Recent

Author Topic: SOLVED How to get PRAGMA result in query or array  (Read 390 times)

JanRoza

  • Hero Member
  • *****
  • Posts: 672
    • http://www.silentwings.nl
SOLVED How to get PRAGMA result in query or array
« on: December 06, 2023, 12:07:38 am »
I tried to get the result of an SQLite PRAGMA statement in a query but I must be doing something wrong as the resulting query stays empty.
I tried the following:
Code: Pascal  [Select][+][-]
  1. qryColumns.Active := false;
  2. qryColumns.SQL.Text := 'SELECT name FROM PRAGMA_TABLE_INFO("Temp_Export")';
  3. qryColumns.Active := true;
  4.  

In a SQLite manager (SQLIteExpert) the PRAGMA statement works perfectly, so the syntax is fine.
I would also like to know how to get the result of the PRAGMA statement into an array (as alternative for a query).
Can anyone get me on the right path?
« Last Edit: December 06, 2023, 01:33:04 am by JanRoza »
OS: Windows 10 (64 bit) / Linux Mint (64 bit)
       Lazarus 3.0 FPC 3.2.2
       CodeTyphon 8.30 FPC 3.3.1

JanRoza

  • Hero Member
  • *****
  • Posts: 672
    • http://www.silentwings.nl
Re: SOLVED How to get PRAGMA result in query or array
« Reply #1 on: December 06, 2023, 01:36:33 am »
It must be the late hour  %), but I already found the answer.
Solved it by using:
Code: Pascal  [Select][+][-]
  1.  
  2.   strSQL := 'INSERT INTO Temp_Columns SELECT name FROM PRAGMA_TABLE_INFO("Temp_Export")';
  3.   DataModule1.DbConnection.ExecuteDirect(strSQL);
  4.   DataModule1.DbTransaction.CommitRetaining;
  5.  

Which gives me a nice table with column names.
OS: Windows 10 (64 bit) / Linux Mint (64 bit)
       Lazarus 3.0 FPC 3.2.2
       CodeTyphon 8.30 FPC 3.3.1

 

TinyPortal © 2005-2018