Page 1 of 1

Calculated Field Not Working

Posted: 2022-09-05 09:10
by thecomputerchap
Hi all, I have this sql statement set in the Calculated Field tab on AppGini...

Code: Select all

SELECT CONCAT("£",(SELECT `Leads`.`AmountAgreed` FROM `Leads` 
WHERE `Leads`.`id`='%ID%') - (SELECT `Leads`.`AmountPaid` FROM `Leads` 
WHERE `Leads`.`id`='%ID%'))
The statement works beautifully in PhpMyAdmin but when I go to the table view of the generated AppGini site, it is showing 0.00 for that column.

I have set the following for the field...
  • Read Only
  • Data Type = Decimal
  • Length = 10
  • Precision = 2
Any ideas?

Darren.

Re: Calculated Field Not Working

Posted: 2022-09-05 10:59
by jsetzer
It seems you try to put an alphanumeric character '£' into a numeric field.

Re: Calculated Field Not Working

Posted: 2022-09-05 11:23
by jsetzer
The statement works beautifully in PhpMyAdmin
Whenever we test our SELECT queries of calculated fields against our database we must not forget that AppGini generated code has to update the column with the return value afterwards. Datatype and perhaps size of the target field must be capable for storing the value. A complete test should include an update of the target field.

Re: Calculated Field Not Working

Posted: 2022-09-05 13:07
by thecomputerchap
That makes perfect sense Jsetzer! I'll try without the £ and see if that fixes the problem.

Once fixed, how can I reformat the field as currency so it hows the £ please?

Cheers,

Dazzy.