Hallo,Velindos hat geschrieben:Hallo,
Funzt nicht!
Reicht nicht!
SQL-Fehler? Keine Ergebnisse? oder zuviele Ergebnisse?
Hallo,Velindos hat geschrieben:Hallo,
Funzt nicht!
natürlich nicht!Reicht nicht!
Code: Alles auswählen
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$, "", "")
;If DatabaseQuery(0, "SELECT load_extension('/usr/lib/sqlite3/pcre.so'); ")
;Else
; Debug DatabaseError()
;EndIf
CheckDatabaseUpdate(0, "CREATE TABLE testtable (id int, txt text, vc varchar)")
CheckDatabaseUpdate(0, "INSERT INTO testtable (id, txt, vc) VALUES ('1', 'abc 11 de', 'QRS 11 TU')")
CheckDatabaseUpdate(0, "INSERT INTO testtable (id, txt, vc) VALUES ('1', 'abc 22 de', 'QRS 22 TU')")
CheckDatabaseUpdate(0, "INSERT INTO testtable (id, txt, vc) VALUES ('1', 'abc 33 de', 'QRS 33 TU')")
q.s = ""
q + "select * from testtable where "
;q + " txt like '%22%' "
q + " txt REGEXP '.*' "
If DatabaseQuery(0, q)
cols = DatabaseColumns(0)
s.s = ""
For i=0 To cols-1
s + " | " + LSet(DatabaseColumnName(0, i), 12, " ")
Next
Debug s
While NextDatabaseRow(0)
s.s = ""
For i=0 To cols-1
s + " | " + LSet(GetDatabaseString(0, i), 12 ," ")
Next
Debug s
Wend
FinishDatabaseQuery(0)
Else
Debug DatabaseError()
EndIf
CloseDatabase(0)
Else
Debug "Can't open database !"
EndIf
Else
Debug "Can't create the database file !"
EndIf
Code: Alles auswählen
UseSQLiteDatabase()
Procedure CheckDatabaseUpdate(Database, Query$)
Result = DatabaseUpdate(Database, Query$)
If Result = 0
Debug DatabaseError()
EndIf
ProcedureReturn Result
EndProcedure
Procedure FindStringEx(String.s, StringToFind.s, StartPosition.i = 1, Mode.i = #PB_String_CaseSensitive)
Protected flag.i = 0, pos.i
If Mode <> #PB_String_CaseSensitive
flag = #PB_RegularExpression_NoCase
EndIf
Protected StringToFindEscaped.s
Protected *c.Character = @StringToFind
While *c\c
Select *c\c
Case '\', '^', '$', '{', '}', '[', ']', '(', ')', '.', '*', '+', '?', '|', '<', '>', '-', '&'
StringToFindEscaped + "\" + Chr(*c\c)
Default
StringToFindEscaped + Chr(*c\c)
EndSelect
*c + SizeOf(Character)
Wend
Protected re.i = CreateRegularExpression(#PB_Any, "\b" + StringToFindEscaped + "\b", #PB_RegularExpression_MultiLine | #PB_RegularExpression_AnyNewLine | flag)
If ExamineRegularExpression(re, String)
While NextRegularExpressionMatch(re)
pos = RegularExpressionMatchPosition(re)
If pos >= StartPosition
Break
EndIf
pos = 0
Wend
EndIf
FreeRegularExpression(re)
ProcedureReturn pos
EndProcedure
DatabaseFile$ = GetTemporaryDirectory()+"Database.sqlite"
If CreateFile(0, DatabaseFile$)
CloseFile(0)
If OpenDatabase(0, DatabaseFile$, "", "")
CheckDatabaseUpdate(0, "CREATE TABLE testtable (id int, txt text)")
CheckDatabaseUpdate(0, "INSERT INTO testtable (id, txt) VALUES ('1', 'ein K11 ist')")
CheckDatabaseUpdate(0, "INSERT INTO testtable (id, txt) VALUES ('1', 'keinK11 ist')")
CheckDatabaseUpdate(0, "INSERT INTO testtable (id, txt) VALUES ('1', 'keinK111 ist')")
q.s = "select * from testtable "
If DatabaseQuery(0, q)
cols = DatabaseColumns(0)
s.s = ""
For i=0 To cols-1
s + " | " + LSet(DatabaseColumnName(0, i), 12, " ")
Next
Debug s
While NextDatabaseRow(0)
colMatch = #False
s.s = ""
For i=0 To cols-1
If FindStringEx(GetDatabaseString(0, i), "K11")
colMatch = #True
EndIf
s + " | " + LSet(GetDatabaseString(0, i), 12 ," ")
Next
If colMatch
Debug s
EndIf
Wend
FinishDatabaseQuery(0)
Else
Debug DatabaseError()
EndIf
CloseDatabase(0)
Else
Debug "Can't open database !"
EndIf
Else
Debug "Can't create the database file !"
EndIf
Code: Alles auswählen
DatabaseFile$ = ":memory:"