How to read boolean from Database?

 

Hi,

I've a system using SQL database. Initially I used a 3rd party API but now I'm transfering to MT5's own Database system.

I'm working with some lines where I'm suppose to read some boolean data from a table and I noticed there is no specific "DatabaseColumn" function for boolean. I assumed it would be the DatabaseColumnInteger (since bool is actually 0 ou 1), but I got an error: "parameter conversion not allowed". I did some research here in the forum and in the docs and couldn't find anything about this.

So which function I'm supposed to use when reading a boolean value from Database?

 

Read the article https://www.mql5.com/en/articles/7463

Use type casting after reading

SQLite: Native handling of SQL databases in MQL5
SQLite: Native handling of SQL databases in MQL5
  • www.mql5.com
The development of trading strategies is associated with handling large amounts of data. Now, you are able to work with databases using SQL queries based on SQLite directly in MQL5. An important feature of this engine is that the entire database is placed in a single file located on a user's PC.
 
Rashid Umarov #:

Read the article https://www.mql5.com/en/articles/7463

Use type casting after reading

Thanks for the reply!

Regarding the article, that's actually the one I've been using to learn how to use the Database system. Problem is, a ctrl+f gave no relevant results about using "bool" with Database (and the same happened with the Forum and Google) :T

Regarding type casting, I think I got it:

//instead
DatabaseColumnInteger(request, column++, opList[aaa].isFake);

//using
int isFake;
DatabaseColumnInteger(request, column++, isFake);
opList[aaa].isFake = bool(isFake);

No more errors messages. Thanks! :)