Jump to content
  • 0

SELECT into Calculated Value


Go to solution Solved by PotatoMato,

Question

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.
Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

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.....

Link to post
Share on other sites
  • 0

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."

 

Link to post
Share on other sites

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.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...