Hi guys,
I had a little problem with an AFL formula that seems to work well when processing with one or a few symbols, but fails with a watch list with many of them. It seems to fail randomly, I mean, processing the same watch list, it stops in one symbol one time and then in a different one, while when processing that one where the SCAN stopped individually, it works well.
Trying to find what happened I have seen my problem seems to be related to a query to a custom MySql database (via ODBC/SQL Plugin). When processing a huge amount of symbols, it seems my database sometimes responds to the Amibroker query with ‘{EMPTY}’, even when the result should be another one since it has the expected data stored). I mean, if I process this symbol individually, Amibroker receives the expected response (the correct data).
You can see an example with ‘CISXF’, where SQL response (stored in ‘LastQ’ variable) fails (due to the ‘{EMPTY}’ value) the first time but then, individually processed, works perfectly.
I have not found the right way to deal with this ‘{EMPTY}’ or wrong response given by my custom database. I am trying to find a way to add a conditional to my code to identify when it happens and to tell Amibroker what to do, but I am confused about what argument has this ’{EMPTY}’.
formula = "SELECT MAX(asOfDate) FROM " + ticker + " ";
LastQ = odbcGetValueSQL(formula);
_TRACE("# " + Name() + "---LastQ: " + LastQ);
LastQ = StrReplace(LastQ, "-", "," );
Seeing ‘Error 5’, I would think ‘LastQ’ argument is a NUMBER, not STRING as expected, but when I use ‘IsEmpy(lastQ)’ or ‘IsTrue(LastQ)’ it seems ‘LastQ’ argument (storing the ‘{EMPTY}’ MySql response) is not a NUMBER, STRING neither an ARRAY.
It would be much appreciated if someone could help me to deal with this issue the right way.
Thanks,