• Welcome, Guest. Please login.
 
November 21, 2019, 03:32:24 pm

News:

Welcome to the SQLitening support forums!


PRAGMA table_info ordlista

Started by Fim, July 27, 2016, 11:03:08 am

Previous topic - Next topic

Fim

slexe "PRAGMA table_info ordlista" gives no result.
Is there any other way to get the names of al columns in a table.
Fim W

cj

July 28, 2016, 03:03:31 pm #1 Last Edit: July 29, 2016, 02:09:17 am by cj
#INCLUDE "sqlitening.inc"
FUNCTION PBMAIN () AS LONG

  LOCAL s AS STRING
  LOCAL columns AS LONG

  slOpen "sample.db3"
s = slGetTableColumnNames("Parts")
  ? PARSE$(s,$NUL,1),,"First in string"
  ? PARSE$(s,$NUL,9),,"Last  in string"

  'Put column names into an array
  columns = PARSECOUNT(s,$NUL)
  DIM sColumnNames(1 TO columns) AS STRING
  PARSE s,sColumnNames(),$NUL
  ? JOIN$(sColumnNames(),$CR),,"All columns in array"
  ? sColumnNames(1),,"First in array"
  ? sColumnNames(columns),,"Last in array"

END FUNCTION

cj

INCLUDE "sqlitening.inc"
FUNCTION PBMAIN () AS LONG
  DIM sColumnNames() AS STRING
  slOpen "sample.db3"
  slSelAry "select * from parts where 1=0",sColumnNames()
  ? JOIN$(sColumnNames(),$CR)
END FUNCTION                 

Fim

Thank you.
A little embarrassed, I had not seen "slGetTableColumnNames" in the manual.
Glad you did not answer RTFM.
Fim W