Sqlite using LIKE % with SetDatabaseString
Posted: Wed Dec 02, 2020 9:32 pm
Hi,
I would like to use the LIKE %? with SetDatabaseString()
Is it possible ?
I would like to use the LIKE %? with SetDatabaseString()
Is it possible ?
Code: Select all
UseSQLiteDatabase()
Procedure CheckDatabaseUpdate(Database, Query$)
Result = DatabaseUpdate(Database, Query$)
If Result = 0
Debug DatabaseError()
EndIf
ProcedureReturn Result
EndProcedure
DatabaseFile$ = GetTemporaryDirectory()+"Database.sqlite"
If CreateFile(0, DatabaseFile$)
CloseFile(0)
If OpenDatabase(0, DatabaseFile$, "", "")
CheckDatabaseUpdate(0, "CREATE TABLE food (name Text)")
CheckDatabaseUpdate(0, "INSERT INTO food (name) VALUES ("+"'test'"+")")
CheckDatabaseUpdate(0, "INSERT INTO food (name) VALUES ("+"'test test lol'"+")")
CheckDatabaseUpdate(0, "INSERT INTO food (name) VALUES ("+"'amha test test lol'"+")")
text.s="test"
SetDatabaseString(0,0,text)
If DatabaseQuery(0, "SELECT * FROM food WHERE name LIKE ? ;")
While NextDatabaseRow(0)
Debug "First "+GetDatabaseString(0, 0)
Wend
FinishDatabaseQuery(0)
EndIf
SetDatabaseString(0,0,text)
If DatabaseQuery(0, "SELECT * FROM food WHERE name LIKE ? % ;")
While NextDatabaseRow(0)
Debug "Second "+GetDatabaseString(0, 0)
Wend
FinishDatabaseQuery(0)
EndIf
CloseDatabase(0)
Else
Debug "Can't open database !"
EndIf
Else
Debug "Can't create the database file !"
EndIf