I use SQL for a database of patients, the original database was created as follows:
And now I need to add a height parameter to my stored patient data. So I can see how to create a similar UpdateDB2_3 function to do that, but I am not sure how to go about actually adding height to the map within that function. I don't want to delete my existing DDB and start over.
Would it be as simple as this, or will this damage my existing database?
B4X:
Sub UpdateDB1_2(sq As SQL)
'empty database, lets create all required tables
Dim m As Map
m.Initialize 'clear the map
m.Put("Patient_No", DBUtils.DB_TEXT)
m.Put("First_Name", DBUtils.DB_TEXT)
m.Put("Last_Name", DBUtils.DB_TEXT)
m.Put("Date_of_Birth", DBUtils.DB_INTEGER)
m.Put("Sex", DBUtils.DB_TEXT)
m.Put("Patient_ID", DBUtils.DB_INTEGER)
DBUtils.CreateTable(sq, "Patients", m, "") 'no primary key assigned
m.Initialize 'clear the map
m.Put("ExamTime", DBUtils.DB_INTEGER)
m.Put("ExamPatient_ID", DBUtils.DB_INTEGER)
m.Put("ExamTestNum", DBUtils.DB_INTEGER)
m.Put("ExamData", DBUtils.DB_BLOB)
DBUtils.CreateTable(sq, "Exams", m, "") 'no primary key assigned
DBUtils.SetDBVersion(sq, 2)
End Sub
And now I need to add a height parameter to my stored patient data. So I can see how to create a similar UpdateDB2_3 function to do that, but I am not sure how to go about actually adding height to the map within that function. I don't want to delete my existing DDB and start over.
Would it be as simple as this, or will this damage my existing database?
B4X:
Sub UpdateDB2_3(sq As SQL)
Dim m As Map
m.Initialize 'clear the map
m.Put("Patient_No", DBUtils.DB_TEXT)
m.Put("First_Name", DBUtils.DB_TEXT)
m.Put("Last_Name", DBUtils.DB_TEXT)
m.Put("Date_of_Birth", DBUtils.DB_INTEGER)
m.Put("Sex", DBUtils.DB_TEXT)
m.Put("Patient_ID", DBUtils.DB_INTEGER)
'now add height
m.Put("Patient_Height", DBUtils.DB_INTEGER)
DBUtils.CreateTable(sq, "Patients", m, "") 'no primary key assigned
DBUtils.SetDBVersion(sq, 3)
End Sub