Code: Select all
********************************************************************************\
*********************
FUNCTION SQLITE_TABLES()
********************************************************************************\
***********************
* Uses a (special) master table where the names of all tables are stored
* Returns an array with names of tables inside of the database
LOCAL aTables := {}
Local cSelect := ""
cSelect := "SELECT name FROM sqlite_master WHERE type IN ('table','name')
AND name NOT LIKE 'sqlite_%' UNION ALL SELECT name FROM sqlite_temp_master WHERE
type IN ('table','name') ORDER BY 1;"
IF DB_IS_OPEN( Database )
aTables := SQLITE_QUERY( Database, cSelect )
msginfo( STR(Len( aTables )))
msginfo(alltrim(aTables) )
ENDIF
RETURN( aTables )
********************************************************************************\
****************************************************
FUNCTION SQLITE_QUERY( Database, cSelect )
********************************************************************************\
****************************************************
LOCAL STMT, nCCount, nI, nCType
LOCAL aRet := {}, oQuery := {}
STMT := sqlite3_prepare( Database, cSelect )
IF STMT_IS_PREPARED( STMT )
DO WHILE sqlite3_step( STMT ) == SQLITE_ROW
oQuery := {}
nCCount := sqlite3_column_count( STMT )
IF nCCount > 0
FOR nI := 1 TO nCCount
nCType := sqlite3_column_type( STMT, nI )
SWITCH nCType
CASE SQLITE_NULL
AADD( oQuery, "NULL")
EXIT
CASE SQLITE_FLOAT
CASE SQLITE_INTEGER
AADD( oQuery, LTRIM(STR( sqlite3_column_int( STMT, nI ) )) )
EXIT
CASE SQLITE_TEXT
AADD( oQuery, sqlite3_column_text( STMT, nI ) )
EXIT
END SWITCH
NEXT nI
ENDIF
aadd(aRet, oQuery)
ENDDO
sqlite3_finalize( STMT )
ENDIF
RETURN( aRet )