Hi,
I have a load of blobs in my database that store test data. I've recently changed the format of the data stored and need to convert the existing blobs to the new format. I have managed to retrieve all of the blobs into a Cursor, it looks like this (simplified):
I am new to SQL so not sure what the neatest way to do this would be, or if I can update each blob as I go along at the comment "not sure how..". Is there a statement I can use to do so?
I don't currently have provision in the project for updating blob data, once an exam is stored it just stays there. I use The current method I use for putting these blobs of examdata into the DDB is below, just in case it has any impact on the question above:
thanks
I have a load of blobs in my database that store test data. I've recently changed the format of the data stored and need to convert the existing blobs to the new format. I have managed to retrieve all of the blobs into a Cursor, it looks like this (simplified):
B4X:
Sub ConvertV4toV5exams()
Dim Cursor1 As Cursor
'Cursor1 = SQL.ExecQuery("SELECT ExamData FROM Exams WHERE ExamTime='"&eT&"' AND ExamPatient_ID='"&eP.patID&"'")
'let's just get all examdata in one go instead
Cursor1 = SQL.ExecQuery("SELECT ExamData FROM Exams")
For tstcnt = 0 To Cursor1.RowCount-1
Dim Buffer() As Byte
Cursor1.Position = tstcnt
Buffer = Cursor1.GetBlob("ExamData")
Dim newtstlist As List
newtstlist.Initialize
newtstlist = ConvertV4blobtoV5(Buffer)
'now serialise the data
Dim raf As RandomAccessFile
File.Delete(tempFolder, tempFile)
raf.Initialize(tempFolder, tempFile, False)
raf.WriteObject(newtstlist, True, raf.CurrentPosition)
raf.Flush
Dim buffer(raf.CurrentPosition) As Byte
raf.ReadBytes(buffer, 0, buffer.Length, 0)
raf.Close
'replace the data stored in the current blob, with this data in 'buffer'
'not sure how...
Next
End Sub
I am new to SQL so not sure what the neatest way to do this would be, or if I can update each blob as I go along at the comment "not sure how..". Is there a statement I can use to do so?
I don't currently have provision in the project for updating blob data, once an exam is stored it just stays there. I use The current method I use for putting these blobs of examdata into the DDB is below, just in case it has any impact on the question above:
B4X:
Sub AddExam (pExam As Exam, pPat As PatientStruct)
Dim ListOfMaps As List
ListOfMaps.Initialize
Dim m As Map
m.Initialize
m.Put("ExamTime", pExam.TimeOfExam)
m.Put("ExamPatient_ID", pPat.patID)
m.Put("ExamTestNum", pExam.NumberOfTests)
m.Put("ExamUploadedStatus", pExam.UploadedStatus)
Dim raf As RandomAccessFile
File.Delete(tempFolder, tempFile)
raf.Initialize(tempFolder, tempFile, False)
raf.WriteObject(pExam.tests, True, raf.CurrentPosition)
raf.Flush
Dim buffer(raf.CurrentPosition) As Byte
raf.ReadBytes(buffer, 0, buffer.Length, 0)
raf.Close
m.Put("ExamData", buffer)
ListOfMaps.Add(m)
DBUtils.InsertMaps(SQL, "Exams", ListOfMaps)
End Sub
thanks
Last edited: