vidierre Posted June 9, 2021 Report Share Posted June 9, 2021 When I insert a record, I want use a fied (named ere_ I have a table representing heirs (named scn_eredi) with these fields: the scn_id referencing a records in the will table named (scn_successioni) the ere_id is a unique id used to build relation between heirs and will tables the ere_num should be a progressive number for each heir-person related to a will To fill the third field I used in webform datapage a calculated value with this formula: SELECT MAX(ere_num)+1 FROM scn_eredi a WHERE a.scn_id = "[@field:scn_id]" I tried the statement both with [@field:scn_id], '[@field:scn_id]' and "[@field:scn_id]" with the same result. It works, but it seems ignoring the WHERE statement. When I insert a second will he do not restart numbering. Quote Link to comment Share on other sites More sharing options...
0 PotatoMato Posted June 9, 2021 Report Share Posted June 9, 2021 Hi @innov2e, instead of WHERE a.scn_id = "[@field:scn_id]", you may use the formula below instead. WHERE a.scn_id = target.[@field:scn_id] -Potato Quote Link to comment Share on other sites More sharing options...
0 vidierre Posted June 9, 2021 Author Report Share Posted June 9, 2021 Excellent! It works, I adjusted the statement in this way to handle the first insertion: SELECT ISNULL(MAX(ere_num)+1,1) FROM scn_eredi a WHERE target.scn_id = '[@field:scn_id]' Noy I have to fill my skill gap goggoling anout target..... Quote Link to comment Share on other sites More sharing options...
0 vidierre Posted June 9, 2021 Author Report Share Posted June 9, 2021 I found this that clarify it to me: "Essentially the source table is the place where the data is coming from and the target table is the place where the data is going to or the table that an action is taking place on. They do not have to be in different schema's or have a different structure to each other and in fact they could actually be the same table." Quote Link to comment Share on other sites More sharing options...
Question
vidierre
SELECT MAX(ere_num)+1 FROM scn_eredi a WHERE a.scn_id = "[@field:scn_id]"
I tried the statement both with [@field:scn_id], '[@field:scn_id]' and "[@field:scn_id]" with the same result.
Link to comment
Share on other sites
3 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.