Home » Community » Newbie corner » SQL + vector related question
SQL + vector related question [message #39929] |
Sun, 12 May 2013 14:12  |
jerson
Messages: 202 Registered: June 2010 Location: Bombay, India
|
Experienced Member |

|
|
I have the following schema
TABLE_ (TEST)
DATE_ (TESTDATE) SQLDEFAULT(CURRENT_DATE)
STRING_ (REFNO ,50)
STRING_ (PATIENT ,50)
STRING_ (DOCTOR ,50)
BLOB_ (OPCOMMENT)
BLOB_ (DOCCOMMENT)
BLOB_ (DATA)
END_TABLE
and these
Vector<Pointf> LeftSeries[4], // 4 series of 12 points each
RightSeries[4];
Vector<Byte> vb; // holds the above 2 sets of data
This is what I have done
BufferStream dat;
dat % LeftSeries[0]
% LeftSeries[1]
% LeftSeries[2]
% LeftSeries[3]
% RightSeries[0]
% RightSeries[1]
% RightSeries[2]
% RightSeries[3];
vb = dat.GetResult();
SQL * Insert(TEST) (REFNO,AsString(~SaveRecord.edtReference))
(DOCTOR,AsString(~SaveRecord.edtDoctor))
(PATIENT,AsString(~SaveRecord.edtPatientName))
(DOCCOMMENT,AsString(~SaveRecord.edtDocComments))
(OPCOMMENT,AsString(~SaveRecord.edtOpComments))
// ***** This line does not work ***** (DATA,vb);
// This is just to make sure I can put something to the DATA blob (DATA,AsString(~SaveRecord.edtOpComments));
I unroll the data like this
// retrieve the data from the bufferstream and show it
BufferStream dat(vb);
dat % LeftSeries[0]
% LeftSeries[1]
% LeftSeries[2]
% LeftSeries[3]
% RightSeries[0]
% RightSeries[1]
% RightSeries[2]
% RightSeries[3];
Question:
How can I save/retrieve the Vector<Byte> to/from the table? This is the first time ever I'm using sqlite3 and serialization, so please forgive my ignorance.
Regards
Jerson
|
|
|
Re: SQL + vector related question [message #39938 is a reply to message #39929] |
Mon, 13 May 2013 18:12  |
jerson
Messages: 202 Registered: June 2010 Location: Bombay, India
|
Experienced Member |

|
|
Follow up
I changed the code to this and I am able to save to the database now. Is there an easier way to achieve this using native U++ utils?
String dat;
for (int i =0;i < LeftSeries[0].GetCount();i++) dat << AsString(LeftSeries[0][i]);
dat << '\r';
for (int i =0;i < LeftSeries[1].GetCount();i++) dat << AsString(LeftSeries[1][i]);
dat << '\r';
for (int i =0;i < LeftSeries[2].GetCount();i++) dat << AsString(LeftSeries[2][i]);
dat << '\r';
for (int i =0;i < LeftSeries[3].GetCount();i++) dat << AsString(LeftSeries[3][i]);
dat << '\r';
for (int i =0;i < RightSeries[0].GetCount();i++) dat << AsString(RightSeries[0][i]);
dat << '\r';
for (int i =0;i < RightSeries[1].GetCount();i++) dat << AsString(RightSeries[1][i]);
dat << '\r';
for (int i =0;i < RightSeries[2].GetCount();i++) dat << AsString(RightSeries[2][i]);
dat << '\r';
for (int i =0;i < RightSeries[3].GetCount();i++) dat << AsString(RightSeries[3][i]);
dat << '\r';
The information in the database is like this
[4, -40][11, -40]
[1, -33][12, -33]
[5, -40][11, -40]
[1, -33][11, -33]
Each line has data for one Vector and can hold a max of 12 points.
How should I re-populate the vector from the string?
Regards
Jerson
|
|
|
Goto Forum:
Current Time: Sun Apr 27 00:15:32 CEST 2025
Total time taken to generate the page: 0.02687 seconds
|