close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Adding Fields in Database

Thread began 6/22/2010 8:14 am by Pardall1955 | Last modified 6/30/2010 12:03 pm by Jimmy Wu | 1193 views | 5 replies |

Pardall1955

Adding Fields in Database

Hi, My question is a little away from the eCart, what I want to really accomplish here is I want to be able to add all values in 6 database columns and store it to another column (total) passing a query into the UPDATE form. Is it possible?

Here is a scenario:

UPDATE operating_expenses SET Total = SUM(Fuel + Grease_Oil + Tire_Repais + Parts + Insurance + License_Fees)

Or perhaps this scenario:

SELECT (Fuel + Grease_Oil + Tire_Repais + Parts + Insurance + License_Fees) AS Total FROM operating_expenses

CAN THIS BE DONE?


Thanks,

Sign in to reply to this post

Jimmy Wu

You could use the SUM function to add the different columns as long as your query only returns one result. If your query returns more than one result, it will add all values from that column from each of the results before adding the different columns.

Sign in to reply to this post

Pardall1955

Ok here is what I got, it works, but it has a delay when I press the Update record, that is: I have to press twice the update to make changes. Or should I say, I have to repeat the update process again in order for it to take effect into the database.

Do you know why this happens?

The other thing is, where can I place this same code into the insert record since the insert page does not have a server behavior.

==================================================================
SELECT OE_ID, Date_, Trip_No, Fuel, Oil_Change, Tire_Repairs, Parts, Insurance, License, Toll,
SUM(Fuel+Oil_Change+Tire_Repairs+Parts+Insurance+License+Toll) AS Total
FROM operating_expenses
WHERE OE_ID = colname
==================================================================

many thanks,

Sign in to reply to this post

Jimmy Wu

That looks like its just selecting values from the database, not making any updates. You would want to use an update sql statement to update the value in the database.

Are the pages you are working with generated by eCart? It seems like insert and update pages are generated by DataAssist, not eCart.

Sign in to reply to this post

Pardall1955

==================================================================
That looks like its just selecting values from the database, not making any updates. You would want to use an update sql statement to update the value in the database.

Are the pages you are working with generated by eCart? It seems like insert and update pages are generated by DataAssist, not eCart.
==================================================================

No, I´m not using eCart, it´s just a simple update page created with DataAssist and I want to be able to change totals as I update with new changes, but also would like to create totals as I insert a new record.
Like I said this sql statement has been placed inside of Server Behavior, it works, but I have to repead the process twice in order to make the changes to the database.

Am I doing this the wrong way, any ideas on how to resolve this???

Thanks again.

Sign in to reply to this post

Jimmy Wu

Ok, I was just checking since you posted in the eCart forum.

Do other values get updated and only the total not getting updated or do none of the values get updated? If you could revert back to the original query, do the values get updated?

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

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.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...