Aggregates SQL with Script

Hi,

We have the following situations :

SITUATION 1:
log('Param : ’ + p_Param); //show param’s value

var selResult = lda.selectSQL("select sum(nfe_item.totalprodutosencargos) as vtotaldanota
from CO_NFENTRADAITENS nfe_item
where
nfe_item.id_co_nfentrada = @p_Param ",{ p_Param: p_Param});

var CO_NFENTRADAITENS = selResult.nextRow();

log('Total : ’ + CO_NFENTRADAITENS[‘vtotaldanota’]);

SITUATION 2:
var selResult2 = lda.selectSQL("select nfe_item.totalprodutosencargos as vtotaldanota
from CO_NFENTRADAITENS nfe_item
where
nfe_item.id_co_nfentrada = @p_Param ",{ p_Param: p_Param});

With both situations we are trying a simple SQL, but the first one doesn’t works with SUM instruction. The second situation is very similar, but without SUM, and it works perfectly. That’s the question: Is there any way to use SUM at scripts without a while syntax?
The param has values and I receive “Undefined”.

The log is attached.

Thanks,

Daniel

Hello Daniel.

Thank you for the report. I have reproduced the problem. Corresponding issue is registered as #62509: Scripting: lda.selectSQL method doesn’t work properly with aggregate fields.

Thanks.