Hello everyone,
i am building an app for data acquisition in which for every series of measurement a new table in a sql database should be created.
Since you cant create a table with variable name easily, i tried to always give the same name "messwerte" and rename after the
measurement is done. However, RENAME TABLE `messwerte` TO ?; seems not to work.
Using jRDC2, my config.properties file looks like this:
In B4A im calling the commands with the following subs:
Am i using RENAME in a wrong way? I also tried ALTER TABLE `messwerte` RENAME TO ?;
The creation of table "messwerte" works perfectly, however RENAME or ALTER both dont rename the tablename.
I hope someone could help me with this.
Philipp
i am building an app for data acquisition in which for every series of measurement a new table in a sql database should be created.
Since you cant create a table with variable name easily, i tried to always give the same name "messwerte" and rename after the
measurement is done. However, RENAME TABLE `messwerte` TO ?; seems not to work.
Using jRDC2, my config.properties file looks like this:
config.properties:
sql.neue_tabelle=CREATE TABLE IF NOT EXISTS messwerte (\
Unix Text,\
Uhrzeit Text,\
Counter TEXT,\
Drehmoment TEXT,\
Kadenz TEXT,\
Fahrradgeschwindigkeit TEXT,\
Platinenspannung TEXT,\
Fahrradakku TEXT,\
Strom TEXT,\
Lng TEXT,\
Lat TEXT,\
GPS_Speed TEXT)
sql.neue_messwerte=INSERT INTO Messwerte VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?),(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?),(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?),(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?),(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?),(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?),(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?),(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?),(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?),(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?),(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?),(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?),(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?),(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?),(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?),(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
sql.rename=RENAME TABLE `messwerte` TO ?;
#sql.rename=ALTER TABLE `messwerte` RENAME TO ?;
In B4A im calling the commands with the following subs:
B4A Subs for calling SQL commands:
Sub Create_Table
rdcLink = "http://" & EditText25.Text & ":" & EditText26.Text & "/rdc" '"http://141.19.77.240:17178/rdc" '
Dim req As DBRequestManager = CreateRequest
Dim cmd As DBCommand = CreateCommand("neue_tabelle", Null)
'Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)
Wait For (req.ExecuteCommand(cmd, Null)) JobDone(j As HttpJob)
Log("Try to create SQL Table")
ToastMessageShow("Try to create SQL Table", False)
If j.Success Then
Log("Table created")
ToastMessageShow("Table created", False)
Else
Log("Table not created")
ToastMessageShow("Table not created", False)
End If
j.Release
End Sub
Sub CloseSQLConnection
rdcLink = "http://" & EditText25.Text & ":" & EditText26.Text & "/rdc" 'rdcLink = "http://141.19.77.240:17178/rdc"
Dim req As DBRequestManager = CreateRequest
Dim name As String = "newtablename"
Dim cmd As DBCommand = CreateCommand("rename", Array(name))
'Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)
Wait For (req.ExecuteCommand(cmd, Null)) JobDone(j As HttpJob)
Log("Tried to rename database. (next time new one is used)")
If j.Success Then
Log("erfolgreich")
Else
Log("fehlgeschlagen")
End If
j.Release
End Sub
Am i using RENAME in a wrong way? I also tried ALTER TABLE `messwerte` RENAME TO ?;
The creation of table "messwerte" works perfectly, however RENAME or ALTER both dont rename the tablename.
I hope someone could help me with this.
Philipp