Working with Databases - page 2

 
Claudius Marius Walter:
The german documentation is horrible.. Sometimes I am very confused. Nevertheless, I will be better (thanks to you!) and can help at least in the German forum at some topics.


At the bottom of this post a table is attached. This table includes additional course data, such as the "number of trades". From these M1 data I would like to make an indicator which shows me for example the number of trades of every bar.

The additional course data is from a custom symbol. I have about 200 Custom symbols. Each custom symbol has about 1 000 000 lines. Therefore, I thought that a database would be the smartest solution. Do you agree with that?

Probably. Not sure it's faster than a simple file, it depends.

Anyway, you need to read all at once at the start, then only update with new data.

 
Hello All,

I'm having a issue with reading back a double array using DatabaseColumnBlob

Sequence:

1/ I change the variable inversionNumber to 123

2/ compile and run 

3/ review the output

4/ change  variable inversionNumber to 456

5/ compile and run

6/ review the output

the  inversionNumber is ONLY used for sanity sake so i can see the DB is being updated  !


First run 



Second run



The Database snippet seems there's a BLOB !

BUT as you can see the values are not being read back 

Code below all error checking removed for clarity.

Any help really appreciated !


string sql, ss;
   int request1, request2; 
   double valueIn[10], valueOut[10];
   int inversionNumber, outversionNumber=0;

   inversionNumber=465; // change after each compile/run to see that a simple datatype is being update in the DB

   // Populate [] with test data
   for (int i=0;i<10;i++) {
      valueIn[i]=(double) i;
      ss=StringFormat("-- > index:%d valueIn %.5f",i,valueIn[i]);
      Print(ss);
   }

   // Prepare BLOB and write to db
   sql="UPDATE TESTTABLE SET versionNumber=?1, minValues=?2 WHERE strategyNumber=1";

   request1=DatabasePrepare(_mainDBHandle, sql);
   DatabaseBind(request1,0,inversionNumber);
   DatabaseBindArray(request1,1,valueIn); 
   DatabaseRead(request1);
   DatabaseFinalize(request1);


   // read back test data 
   sql="SELECT versionNumber, minValues FROM TESTTABLE WHERE strategyNumber=1";
   request2=DatabasePrepare(_mainDBHandle,sql);
 
   DatabaseRead(request2);
   DatabaseColumnInteger(request2,0,outversionNumber);
   DatabaseColumnBlob(request2,1,valueOut);

   Print("Version number read back from DB ",outversionNumber);
   for (int i=0;i<10;i++) {
      ss=StringFormat("-- > index:%d valueOut %.5f ",i, valueOut[i]);
      Print(ss);
   }





Reason: