Help with Calculated Field PLEASE!!

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
User avatar
richard
Posts: 15
Joined: 2023-03-22 13:08
Location: Oroville CA
Contact:

Help with Calculated Field PLEASE!!

Post by richard » 2024-07-01 15:46

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 ?

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1869
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Help with Calculated Field PLEASE!!

Post by jsetzer » 2024-07-01 18:13

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.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.14 Revision 1665 + all AppGini Helper tools

User avatar
richard
Posts: 15
Joined: 2023-03-22 13:08
Location: Oroville CA
Contact:

Re: Help with Calculated Field PLEASE!!

Post by richard » 2024-07-02 18:21

Thanks for the help, I just figured it out as you sent me the answer.

Post Reply