This might give you a handle on what's going on under the hood. No coffee required, but no warranty supplied either. ?
This Sub to
convert a typed-in search string (possibly multiple words) to the "WHERE ..." part of a SQL query:
B4X:
Sub ShelbyWhere(SearchWords As String) As String
Log("SearchWords = """ & SearchWords & """")
Dim Words() As String = Regex.Split(" ", SearchWords.Trim)
Dim sb As StringBuilder
sb.Initialize
For I = 0 To Words.Length - 1
Dim ThisWord As String = Words(I).Trim
Logg("Word " & I & " = """ & ThisWord & """")
If ThisWord.Length <> 0 Then
ThisWord = ThisWord.Replace("'", "_") 'change apostrophe to match-any-character
ThisWord = ThisWord.Replace("%", "_") 'change percentage to match-any-character
ThisWord = ThisWord.Replace("*", "%") 'change commonly-known * wildcard to SQL wildcard %
ThisWord = ThisWord.Replace("?", "_") 'change commonly-known ? wildcard to SQL wildcard _
ThisWord = "%" & ThisWord & "%" 'add leading and trailing wildcards to do ".Contains" match
ThisWord = ThisWord.Replace("%%", "%") 'to be sure, to be sure
If sb.Length <> 0 Then
sb.Append(" OR ")
End If
sb.Append("DescriptionSubjectLookup LIKE '" & ThisWord & "'")
End If
Next
If sb.Length = 0 Then
Return ""
Else
Return "WHERE " & sb.ToString
End If
End Sub
This Sub to
search your database and display all records matching the "WHERE ..." generated above:
B4X:
Sub ShelbyShow(WhereClause As String)
Dim sql As SQL
sql.Initialize(File.DirInternal, "dbircv11.db", False)
Dim FullQuery As String = ("SELECT DescriptionSubjectLookup, TableNumber, rowid FROM TableList221 " & WhereClause).Trim
Log("WhereClause = " & WhereClause)
Log("FullQuery = " & FullQuery)
Dim csr As Cursor = sql.ExecQuery(FullQuery)
Log("RowCount = " & csr.RowCount)
Log("ColumnCount = " & csr.ColumnCount)
For I = 0 To csr.RowCount - 1
If I < 20 Then
csr.Position = I
Log(I & TAB & csr.GetString2(2) & TAB & csr.GetString2(1) & TAB & csr.GetString2(0))
Else
Log("and another " & (csr.RowCount - I) & " rows...")
Exit
End If
Next
sql.Close
End Sub
Test it with:
B4X:
ShelbyShow(ShelbyWhere(""))
ShelbyShow(ShelbyWhere("index"))
ShelbyShow(ShelbyWhere("brace"))
ShelbyShow(ShelbyWhere("build"))
ShelbyShow(ShelbyWhere("freez"))
ShelbyShow(ShelbyWhere("roosters"))
ShelbyShow(ShelbyWhere("chickens"))
ShelbyShow(ShelbyWhere("seis"))
ShelbyShow(ShelbyWhere("seis roosters"))
ShelbyShow(ShelbyWhere("chickens seis roosters"))
and
with luck you'll get something like this:
[CODE lang="json" title="Log output" highlight="5,9,32,36,45,49,56,60,81,85,94,98,100,104,106,110,124,129,143,149,"]Logger connected to: HMD Global Nokia C01 Plus
--------- beginning of system
--------- beginning of main
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
SearchWords = ""
Word 0 = ""
WhereClause =
FullQuery = SELECT DescriptionSubjectLookup, TableNumber, rowid FROM TableList221
RowCount = 449
ColumnCount = 3
0 1 R403.3(2)pg1 A Tues 12/06/22 Air-Freezing Index For U.S. Locations (State, County, index) Alabama-Indiana pg1
1 3 R702.4.2 Backer Board Materials (Material, Standard)
2 4 R404.1.2(2) Foundation Concrete Basement Walls Vertical Reinforcement 6 Inch Thickness (Height, Backfill, Bar, Spacing, Soil)
3 5 R404.1.2(1) Foundation Concrete Basement Walls Horizontal Reinforcement (Height, Location)
4 6 R602.10.1.3 Braced Wall Line Spacing (Application, Condition, Building Type, Spacing)
5 7 R602.10.5 Braced Wall Panel Minimum Length (Method, Minimum Length, Contributing Length)
6 8 R602.10.5.2 Braced Wall Panel -Partial Credit- Less Than 4' Length (Length, Wall Height)
7 9 R602.10.6.1 Braced Wall Panels - Minimum Hold-Down Forces (Seismic Category & Wind Speed, Supporting/Story, Hold-Down Force)
8 10 R602.10.6.4 Braced Wall Tension Strap Resisting Wind Pressure Capacity (Stud Size & Grade, Pony Height, Opening, Tension Strap Capacity)
9 11 R602.10.3(3)pg1 Bracing Wall Based On Seismic Design( Wall Dimensions, Methods, Panels) pg1
10 12 R602.10.4pg1 Bracing Wall Methods (Method, Thickness, Materials, Figure, Fasteners, Spacing) pg1
11 13 R602.10.3(1)pg1 Bracing Walls Requirements Based On Wind Speed (Exposure Category, Minimum Panels) pg1
12 14 R602.10.6.5 Bracing Wall Requirements Brick Veneer-Wood Structural Panels (Seismic Category, Story, Wall Line Length, Hold-Down Force)
13 15 R602.10.3(4) Bracing Wall Seismic Adjustment Factors (Basis, Story, Condition, Methods)
14 16 R602.12.4 Bracing Wall Minimum Number Of Units Requirement- Sides Of Rectangle (Wind Speed, Story, Ridge Height, Number Of Units)
15 17 R602.10.3(2) Bracing Wall Wind Adjustment Factors (Item Number, Adjustment, Stories For Support, Condition, Methods)
16 18 R502.3.3(1) Cantilever Spans-Supporting Wall & Roof, Exterior Balcony (Member & Spacing, Maximum Cantilever Span [Snow, Roof Width])
17 19 R802.5.1(1)pg1 Ceiling Joist Spans, Uninhabitable Attics-Without Storage, Live Load 10 (Spacing, Species, Dead Load, Joist Size) pg 1
18 20 R804.3.1.1(1) Ceiling Joist Steel Spans Live Load 10-No Attic Storage (Member, Allowable Span, Bracing)
19 22 N1101.7.2(2) Climate Zone Definitions International (Zone Number,Thermal Criteria)
and another 429 rows...
SearchWords = "index"
Word 0 = "index"
WhereClause = WHERE DescriptionSubjectLookup LIKE '%index%'
FullQuery = SELECT DescriptionSubjectLookup, TableNumber, rowid FROM TableList221 WHERE DescriptionSubjectLookup LIKE '%index%'
RowCount = 7
ColumnCount = 3
0 1 R403.3(2)pg1 A Tues 12/06/22 Air-Freezing Index For U.S. Locations (State, County, index) Alabama-Indiana pg1
1 71 N1106.4 Energy Maximum Rating Index (Climate Zone, Rating Iindex)
2 94 R403.3(1) Footings- Frost-Protected Depth & Insulation (Freeze Index, Vertical & Horizontal R-value)
3 487 R403.3(2)pg2 Air-Freezing Index For U.S. Locations (State, County, index) Iowa-Minnesota pg2
4 488 R403.3(2)pg3 Air-Freezing Index For U.S. Locations (State, County, index) Mississippi-North Carolina pg3
5 489 R403.3(2)pg4 Air-Freezing Index For U.S. Locations (State, County, index) North Dakota-Utah pg4
6 490 R403.3(2)pg5 Air-Freezing Index For U.S. Locations (State, County, index) Vermont-Wyoming pg5
SearchWords = "brace"
Word 0 = "brace"
WhereClause = WHERE DescriptionSubjectLookup LIKE '%brace%'
FullQuery = SELECT DescriptionSubjectLookup, TableNumber, rowid FROM TableList221 WHERE DescriptionSubjectLookup LIKE '%brace%'
RowCount = 5
ColumnCount = 3
0 6 R602.10.1.3 Braced Wall Line Spacing (Application, Condition, Building Type, Spacing)
1 7 R602.10.5 Braced Wall Panel Minimum Length (Method, Minimum Length, Contributing Length)
2 8 R602.10.5.2 Braced Wall Panel -Partial Credit- Less Than 4' Length (Length, Wall Height)
3 9 R602.10.6.1 Braced Wall Panels - Minimum Hold-Down Forces (Seismic Category & Wind Speed, Supporting/Story, Hold-Down Force)
4 10 R602.10.6.4 Braced Wall Tension Strap Resisting Wind Pressure Capacity (Stud Size & Grade, Pony Height, Opening, Tension Strap Capacity)
SearchWords = "build"
Word 0 = "build"
WhereClause = WHERE DescriptionSubjectLookup LIKE '%build%'
FullQuery = SELECT DescriptionSubjectLookup, TableNumber, rowid FROM TableList221 WHERE DescriptionSubjectLookup LIKE '%build%'
RowCount = 19
ColumnCount = 3
0 6 R602.10.1.3 Braced Wall Line Spacing (Application, Condition, Building Type, Spacing)
1 70 N1105.5.2(1)pg1 Energy Efficiency Design Specifications For Building Components (Component, Standard) pg1
2 123 R301.5 Live Loads-Minimum Uniformly Distributed (Use In Building Areas, Live Load)
3 186 R610.5(1) Wall SIP Minimum Thickness Supports SIP Or Light-Frame Roof (Building Width, Wind, Snow Load)
4 187 R610.5(2) Wall SIP Minimum Thickness Supports SIP Or Light-Frame 1 Story & Roof (Building Width, Wind, Snow load)
5 200 R603.3.2(2) Stud Steel Sizing Roof & Ceiling 28' (Width Of Building, Wind, Category, Stud Thickness, Snow)
6 214 R603.3.2(1) Wall Fastening Schedule [Steel] (Building Element, Number Of Fasteners, Spacing)
7 257 G2413.4(19) Pipe-Propane Polyethylene Plastic 11PSI Drop .5 PSI [Capacity Per Sizing Regulator to Building] (Use, Length, Diameter, Capacity Btu/Hr.)
8 258 G2413.4(21) Pipe-Propane Polyethylene Plastic 11 PSI Drop .5 PSI [Capacity Per Sizing Regulator to Building] (Length, Diameter, Capacity Cu.Ft./Hr.)
9 297 P3002.1(2) Sanitary Drainage & Vent Pipe Underground Building Standard (Pipe Type, Standard)
10 298 P3002.2 Sanitary Building Sewer Pipe Standard (Material, Standard)
11 303 P3005.4.2 Sanitary Fixture Units Allowed Connected Building Drain, Branches Or Sewer (Pipe Diameter, Slope Per Foot)
12 376 R505.3.1(2) Floor Fastening Schedule (Building Elements, Number & size Fasteners, Spacing)
13 388 R603.3.2(4) Stud Steel Sizing Roof & Ceiling 32' (Width Of Building, Wind, Category, Stud Thickness, Snow)
14 389 R603.3.2(5) Stud Steel Sizing Roof & Ceiling 36' (Width Of Building, Wind, Category, Stud Thickness, Snow)
15 390 R603.3.2(6) Stud Steel Sizing Roof & Ceiling 40' (Width Of Building, Wind, Category, Stud Thickness, Snow)
16 391 R603.3.2(3) Stud Steel Sizing Roof & Ceiling (Width Of Building, Wind, Category, Stud Thickness, Snow)
17 463 N1105.5.2(1)pg2 Energy Efficiency Design Specifications For Building Components (Component, Standard) pg2
18 464 N1105.5.2(1)pg3 Energy Efficiency Design Specifications For Building Components (Component, Standard) pg3
SearchWords = "freez"
Word 0 = "freez"
WhereClause = WHERE DescriptionSubjectLookup LIKE '%freez%'
FullQuery = SELECT DescriptionSubjectLookup, TableNumber, rowid FROM TableList221 WHERE DescriptionSubjectLookup LIKE '%freez%'
RowCount = 7
ColumnCount = 3
0 1 R403.3(2)pg1 A Tues 12/06/22 Air-Freezing Index For U.S. Locations (State, County, index) Alabama-Indiana pg1
1 24 R301.2(1) Climatic Design Criteria (Wind Design, Damage from, Ice, Flood, Freezing)
2 94 R403.3(1) Footings- Frost-Protected Depth & Insulation (Freeze Index, Vertical & Horizontal R-value)
3 487 R403.3(2)pg2 Air-Freezing Index For U.S. Locations (State, County, index) Iowa-Minnesota pg2
4 488 R403.3(2)pg3 Air-Freezing Index For U.S. Locations (State, County, index) Mississippi-North Carolina pg3
5 489 R403.3(2)pg4 Air-Freezing Index For U.S. Locations (State, County, index) North Dakota-Utah pg4
6 490 R403.3(2)pg5 Air-Freezing Index For U.S. Locations (State, County, index) Vermont-Wyoming pg5
SearchWords = "roosters"
Word 0 = "roosters"
WhereClause = WHERE DescriptionSubjectLookup LIKE '%roosters%'
FullQuery = SELECT DescriptionSubjectLookup, TableNumber, rowid FROM TableList221 WHERE DescriptionSubjectLookup LIKE '%roosters%'
RowCount = 0
ColumnCount = 3
SearchWords = "chickens"
Word 0 = "chickens"
WhereClause = WHERE DescriptionSubjectLookup LIKE '%chickens%'
FullQuery = SELECT DescriptionSubjectLookup, TableNumber, rowid FROM TableList221 WHERE DescriptionSubjectLookup LIKE '%chickens%'
RowCount = 0
ColumnCount = 3
SearchWords = "seis"
Word 0 = "seis"
WhereClause = WHERE DescriptionSubjectLookup LIKE '%seis%'
FullQuery = SELECT DescriptionSubjectLookup, TableNumber, rowid FROM TableList221 WHERE DescriptionSubjectLookup LIKE '%seis%'
RowCount = 12
ColumnCount = 3
0 9 R602.10.6.1 Braced Wall Panels - Minimum Hold-Down Forces (Seismic Category & Wind Speed, Supporting/Story, Hold-Down Force)
1 11 R602.10.3(3)pg1 Bracing Wall Based On Seismic Design( Wall Dimensions, Methods, Panels) pg1
2 14 R602.10.6.5 Bracing Wall Requirements Brick Veneer-Wood Structural Panels (Seismic Category, Story, Wall Line Length, Hold-Down Force)
3 15 R602.10.3(4) Bracing Wall Seismic Adjustment Factors (Basis, Story, Condition, Methods)
4 126 R606.12.4.2 Masonry Stacked Bonded Seismic D2, Lateral Resisting (Thickness, Bar Size Spaced 16" o.c.)
5 127 R606.12.4.1 Masonry Stacked Bonded Wall In Seismic D2,Non Lateral Resisting (Thickness, Bar Size Spaced 24" o.c.)
6 132 R606.12.2.1 Masonry Wall Min Length Ext. (Seismic, Top Story, Light-Frame, Masonry 2nd Story,Roof)
7 134 R606.12.3.2 Masonry Wall Reinforcement Seismic (Thickness, Sum-Rebar-Areas, Bar-Size)
8 179 R301.2.2.1.1 Seismic Design Category Determination (Calculated Speeds, Seismic Design Category)
9 210 R703.8(1) Veneer Stone Or Masonry Seismic Limitations & Requirements (Seismic Design Category- A,B,C Number Of Stories, Height, Thickness, Weight)
10 386 R602.10.3(3)pg2 Bracing Wall Based On Seismic Design( Wall Dimensions, Methods, Panels) pg2
11 422 R703.8(2) Veneer Stone Or Masonry Seismic Limitations & Requirements (Seismic Design Category- D0,D1,D2 Number Of Stories, Height, Thickness, Weight)
SearchWords = "seis roosters"
Word 0 = "seis"
Word 1 = "roosters"
WhereClause = WHERE DescriptionSubjectLookup LIKE '%seis%' OR DescriptionSubjectLookup LIKE '%roosters%'
FullQuery = SELECT DescriptionSubjectLookup, TableNumber, rowid FROM TableList221 WHERE DescriptionSubjectLookup LIKE '%seis%' OR DescriptionSubjectLookup LIKE '%roosters%'
RowCount = 12
ColumnCount = 3
0 9 R602.10.6.1 Braced Wall Panels - Minimum Hold-Down Forces (Seismic Category & Wind Speed, Supporting/Story, Hold-Down Force)
1 11 R602.10.3(3)pg1 Bracing Wall Based On Seismic Design( Wall Dimensions, Methods, Panels) pg1
2 14 R602.10.6.5 Bracing Wall Requirements Brick Veneer-Wood Structural Panels (Seismic Category, Story, Wall Line Length, Hold-Down Force)
3 15 R602.10.3(4) Bracing Wall Seismic Adjustment Factors (Basis, Story, Condition, Methods)
4 126 R606.12.4.2 Masonry Stacked Bonded Seismic D2, Lateral Resisting (Thickness, Bar Size Spaced 16" o.c.)
5 127 R606.12.4.1 Masonry Stacked Bonded Wall In Seismic D2,Non Lateral Resisting (Thickness, Bar Size Spaced 24" o.c.)
6 132 R606.12.2.1 Masonry Wall Min Length Ext. (Seismic, Top Story, Light-Frame, Masonry 2nd Story,Roof)
7 134 R606.12.3.2 Masonry Wall Reinforcement Seismic (Thickness, Sum-Rebar-Areas, Bar-Size)
8 179 R301.2.2.1.1 Seismic Design Category Determination (Calculated Speeds, Seismic Design Category)
9 210 R703.8(1) Veneer Stone Or Masonry Seismic Limitations & Requirements (Seismic Design Category- A,B,C Number Of Stories, Height, Thickness, Weight)
10 386 R602.10.3(3)pg2 Bracing Wall Based On Seismic Design( Wall Dimensions, Methods, Panels) pg2
11 422 R703.8(2) Veneer Stone Or Masonry Seismic Limitations & Requirements (Seismic Design Category- D0,D1,D2 Number Of Stories, Height, Thickness, Weight)
SearchWords = "chickens seis roosters"
Word 0 = "chickens"
Word 1 = "seis"
Word 2 = "roosters"
WhereClause = WHERE DescriptionSubjectLookup LIKE '%chickens%' OR DescriptionSubjectLookup LIKE '%seis%' OR DescriptionSubjectLookup LIKE '%roosters%'
FullQuery = SELECT DescriptionSubjectLookup, TableNumber, rowid FROM TableList221 WHERE DescriptionSubjectLookup LIKE '%chickens%' OR DescriptionSubjectLookup LIKE '%seis%' OR DescriptionSubjectLookup LIKE '%roosters%'
RowCount = 12
ColumnCount = 3
0 9 R602.10.6.1 Braced Wall Panels - Minimum Hold-Down Forces (Seismic Category & Wind Speed, Supporting/Story, Hold-Down Force)
1 11 R602.10.3(3)pg1 Bracing Wall Based On Seismic Design( Wall Dimensions, Methods, Panels) pg1
2 14 R602.10.6.5 Bracing Wall Requirements Brick Veneer-Wood Structural Panels (Seismic Category, Story, Wall Line Length, Hold-Down Force)
3 15 R602.10.3(4) Bracing Wall Seismic Adjustment Factors (Basis, Story, Condition, Methods)
4 126 R606.12.4.2 Masonry Stacked Bonded Seismic D2, Lateral Resisting (Thickness, Bar Size Spaced 16" o.c.)
5 127 R606.12.4.1 Masonry Stacked Bonded Wall In Seismic D2,Non Lateral Resisting (Thickness, Bar Size Spaced 24" o.c.)
6 132 R606.12.2.1 Masonry Wall Min Length Ext. (Seismic, Top Story, Light-Frame, Masonry 2nd Story,Roof)
7 134 R606.12.3.2 Masonry Wall Reinforcement Seismic (Thickness, Sum-Rebar-Areas, Bar-Size)
8 179 R301.2.2.1.1 Seismic Design Category Determination (Calculated Speeds, Seismic Design Category)
9 210 R703.8(1) Veneer Stone Or Masonry Seismic Limitations & Requirements (Seismic Design Category- A,B,C Number Of Stories, Height, Thickness, Weight)
10 386 R602.10.3(3)pg2 Bracing Wall Based On Seismic Design( Wall Dimensions, Methods, Panels) pg2
11 422 R703.8(2) Veneer Stone Or Masonry Seismic Limitations & Requirements (Seismic Design Category- D0,D1,D2 Number Of Stories, Height, Thickness, Weight)[/CODE]