Page 1 of 1
Help with Calculated Field PLEASE!!
Posted: 2024-07-01 15:46
by richard
I have a field called invoice_number and I am trying to calculate it's value. It is an integer.
Here is my code:
INSERT INTO `invoice` (`invoice_number`)
VALUE ( `%ID%` + 1000)
WHERE `invoice`.`ID` = `%ID%`;
it does not work, what am I doing wrong ?
Re: Help with Calculated Field PLEASE!!
Posted: 2024-07-01 18:13
by jsetzer
INSERT INTO `invoice` (`invoice_number`)
(1) SQL queries for Calculated Fields in AG must return exactly one value. You have to define a
SELECT
statement rather than an
INSERT
command.
---
WHERE `invoice`.`ID` = `%ID%`
(2) Also, always use proper qoutes:
single qoutes
'
for
'values'
and backticks
`
for table- and column-names
`tn`.`cn`
---
Try this instead:
Code: Select all
SELECT 12345
FROM `invoice`
WHERE `invoice`.`ID` = '%ID%';
Replace
12345
by the formula you need.
Tip
Whenever you have problems with custom database commands, check for SQL errors in Administration area.
Wish
When posting here,
please always put code fragments inside
[code]...[/code]
blocks for better readability.
Re: Help with Calculated Field PLEASE!!
Posted: 2024-07-02 18:21
by richard
Thanks for the help, I just figured it out as you sent me the answer.