This topic is locked

Event trigers write to database

10/9/2007 10:03:53 PM
ASPRunnerPro General questions
S
stealthwifi author

Hi Sergey!
I am going to be transfering my old project to the new version of ASP runner - I'm loving the charting great job!
This project is for an insurance company and bassicly my question is to enable trending of our data. Pretty simple master detail database where you enter a policy number and then the detail is all the claims for that policy number.
Now when a user edits the "valuation date" on the (master) policy number before that change takes effect I need all the claims that are dependent on that policy number to be sent to a new table. It can only happen when the "valuation date" is changed and not any other part of that line. This is so the user can then go and make the changes to the individual claims and the database will have a backup and the ability to look up past data values. If possible the table should be created when the field is edited and have the policy number, user's name and date/time stamp of when the edit took place. I am thinking of using the Before Record Updated event and an IF statement to see if the "valuation date" is the one being update If it is then using the built in save old data record in another table to save the old data and all "claims" that are dependent on that "policy number".
Any suggestions or code samples that any one could offer or any better way's to do this would be a great help.

Thank you all for all your assistance in advance it is much aprciated!! <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=6478&image=1&table=forumtopics' class='bbc_emoticon' alt=':)' />
Stealth-

Sergey Kornilov admin 10/10/2007

I recommend you to check sample actions and sample events that can be found in ASPRunnerPro manual.
This can give you an idea of how to write data to the database.

S
stealthwifi author 10/10/2007

Ok so i fixed my last error and now when any field in the Policy is changed All items are saved over to the Trend table LOL.
Now i have to come up with a WHERE clause to limit it so just the items linked to the policy number that is being changed are saved into the Trend table instead of everything. Any ideas on Syntax for that?
Also i need to add an If clause so the data only gets sent to the "Trend" table If the thign being changed is the "Valuation".

Do you know the syntax to define a change so I could put it as... If dict.("Valuation") = (code to ID thing being changed) Then (proceed with SQL statement to copy data into Trend table)?

S
stealthwifi author 10/10/2007

I have the statement and the WHERE all set up now and working perfect. It shoots the data pre change over to the trending table and just that data that is linked to that partecular record.
Only thing left is the If statement so it only happens If the "Valuation" is whats being edited. Any ideas the syntax for the If statement?
Thanks all!
Cheers - Stealth

S
stealthwifi author 10/11/2007

For my If statement I tried:
If oldvalues("Valuation") = dict("Valuation") then

-------code-----

end if
the problum is that when testing i edit the valuation field to stay the same and used a response.write to see what the values will be.

the Oldvalues("Valuation") displays in the format 9/28/2007

and dict("Valuation") displays in the format 2007-9-28
All the tables in the SQL DB that have anything to do with the Valuation field are all set to smalldatetime but the data is still in 2 diffrent formats?
I think the logic in the If statment will work I will just have to use the syntax to change equal to not equal.
Any ideas as to why AspRunner views 9/28/2007 & 2007-9-28 as not being equal?
Cheers- Stealth

Sergey Kornilov admin 10/11/2007

You can use the following:

If CDate(oldvalues("Valuation")) = CDate(dict("Valuation")) then
S
stealthwifi author 10/11/2007

You can use the following:


If CDate(oldvalues("Valuation")) = CDate(dict("Valuation")) then


Worked absolutly perfect thank you very much!!!!! <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=22170&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' />
Cheers - Stealth