I have a DB with 53 columns and wanted to create a generalised method to create a SQL table and B4xTableView
The following shows the B4X Col Names which I use for the headers in the table and the DB items.. Only the first three are shown
This shows query for the setup of the SQL
Creates the DB and works fine, and I can write to B4X table using the same headers
However if I try to develop a generalised solution for a much larger SQL DB then problems
This is one solution using the above three items
As I can't enter as string value "$"" I have had to use "$" & chr(34).
This logs identically to the first Query but SQL does not recognize the $ character..
I am sure that writing this way negates the literal operator $" "$
Is there any other way to approach this?
The following shows the B4X Col Names which I use for the headers in the table and the DB items.. Only the first three are shown
B4X:
Starter.DBName = "CABLES"
Starter.TotColNumber=3 '53 in final count
Starter.FrozenCols=3
Starter.FirstColCheck=False
Starter.ColNames(0) = "No_CORES"
Starter.ColNames(1) = "AREA_MM2"
Starter.ColNames(2) = "TYPE"
Starter.ColDataTypes(0) = "INT"
Starter.ColDataTypes(1) = "TEXT"
Starter.ColDataTypes(2) = "TEXT"
This shows query for the setup of the SQL
B4X:
Query = $"CREATE TABLE CABLES (${Starter.ColNames(0)} TEXT,${Starter.ColNames(1)} TEXT,${Starter.ColNames(2)} TEXT) "$
Starter.SQLCABLE.ExecNonQuery( Query )
Creates the DB and works fine, and I can write to B4X table using the same headers
However if I try to develop a generalised solution for a much larger SQL DB then problems
This is one solution using the above three items
B4X:
Query = "$" & Chr(34) & "CREATE TABLE CABLES ("
For i = 0 To Starter.TotColNumber-2
Query = Query & "${Starter.ColNames(" & i & ")} TEXT , "
Next
Dim i As Int = Starter.TotColNumber-1
Query = Query & "${Starter.ColNames(" & i & ")} TEXT)" & Chr(34) & "$" ' adds in final element without comma
As I can't enter as string value "$"" I have had to use "$" & chr(34).
This logs identically to the first Query but SQL does not recognize the $ character..
I am sure that writing this way negates the literal operator $" "$
Is there any other way to approach this?