insert into two tables
Hi,
How would i use Data Assist to insert into two tables at once?
I need to be able to insert into the products table and at same time insert the amount into the payments table?
Many thanks
Hi,
How would i use Data Assist to insert into two tables at once?
I need to be able to insert into the products table and at same time insert the amount into the payments table?
Many thanks
Use two Insert record behavior on the page, one to perform the insert to the products tabel, the second to insert to the payments table.
You have (2) tables
products
payments
You can have one page that does both entries to the tables. You'll need a form that performs a POST to store the data to your tables. The submit button will trigger the store action.
Create (2) separate INSERT behaviors for each table triggered off of the same submit button.
hey thanks for that, the payments fields are hidden and need to get the values from the products insert i.e. amount
will that work with the two server behaviours off one submit button?
thanks again
yes, you can use the two insert behaviors and trigger them off the same submit button.
thanks tom92909 and jason, having trouble implimenting.
i added the second insert behavior to my form however it comes back when i insert with:
Column 'ProductID' cannot be null
the ProductID should get is value from the InsuranceID which i have set it to by clicking the lightning bolt and selected my hidden form field InsuranceID in my form.
I am guessing that because it does not get a value until it inserts into the database this is why it shows as null in my ProductID ?
any ideas how to get around this?
thanks guys
If the first Insert record behavior insert to the Insurance table, it will store the insurance ID in a session variable.
In the second insert record behavior, you should bind the product id column to the session variable created by the first insert record behavior.
just an addition info.. if you like to know what the session name that stored the last insert id, you could look at the source code and find something like this:
$WA_sessionName = "WADA_xxxxxxxxxxxx";
if you have multiple form in a page... this method will be helpfull since DataAssist create Session binding in every insert record behavior.
thanks guys, so will it get it from the session variable even if they are both triggered on the same submitt button?
is there a way to set the order of the inserts or does that not matter?
thanks again
yes it will still set the session.
The order they are added to the code is the order you add them.
add the insert record behavior for the parent table first, then add the insert record behavior for the child table.
Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.
These out-of-the-box solutions provide you proven, tested applications that can be up and running now. Build a store, a gallery, or a web-based email solution.