![]() |
lefty author 2/11/2012 |
I have the need to update a field in another table . It is a calculation in one table that updates the running total in another table .
|
![]() |
lefty author 2/13/2012 |
I have the need to update a field in another table . It is a calculation in one table that updates the running total in another table . ex. Table Orders fldqty * fldcost after Record updated event ex. Table Inventory fldInv = fldInv - fldqty(from Orders Table on the fly for only the record updated)
|
![]() |
Sergey Kornilov admin 2/13/2012 |
As a universal advice - print SQL query on the page instead of executing to see what might be wrong and what is causing type mismatch error. |
![]() |
lefty author 2/14/2012 |
As a universal advice - print SQL query on the page instead of executing to see what might be wrong and what is causing type mismatch error.
|
![]() |
Sergey Kornilov admin 2/14/2012 |
My suggestion is to print your custom query on the page rather than turning debug mode on. |
![]() |
lefty author 2/15/2012 |
Thanks Sergey for getting back to me on this but I set debug mode to true . It only gets past the original SQL query . When I use the update statement This is after Record Updated. sql ="update POS_Inventory set fldinv = fldinv - " & values("posinv")& " where pos = ' " & dict("fldavail") & "'" customQuery(sql) ( fldinv is from the table to be updated as well as pos which is not updated but matches value in original table) I get expected end of statement on server but before building syntax okay on check ASPrunner syntax check ; so I put a Calculated field in my updating table and tried to use that instead it is (read only) and used this query sql ="update POS_Inventory set fldinv = " & values("totpos")& " Where pos=" & values("fldavail") customQuery(sql) ( fldinv is from the table to be updated as well as pos which is not updated but matches value in original table) Type Mismatch error Note Where statement are text fields and if I take out where it still does not update calculated field values("totpos") which is a calculated field in editor custom field rs("posinv) - rs("fldqty") all it gives on nonfriendly error messages. Note : I haven't used update statements to often with SQL ; read your manual and also tried the following without a new query . Not sure if I need a coresponding query with the below either as the values should already be queried. The param ; I used old values because the read only field when updated should use the old value first to update the other table . Not to confuse but the below was tried after the above codes ; either of the 3 has not worked Did not work either below. "No corresponding query . As The values below are should already be queried. except for the fldinv feild on the other table to be updated" the sample below according to your manual should update but don't know how it would just update the current record without knowing the key field. ??? dal.Table("POS_Inventory").Param("fldinv")=oldvalues("posinv") dal.Table("POS_Inventory").Value("fldinv")=values("posinv") dal.Table("POS_Inventory").Update() values.Remove("fldinv")
|
![]() |
Sergey Kornilov admin 2/15/2012 |
I guess this query gives you trouble: update POS_Inventory set fldinv =' ' Where pos='tshirts'
|
![]() |
lefty author 2/15/2012 |
I guess this query gives you trouble: update POS_Inventory set fldinv =' ' Where pos='tshirts'
|
![]() |
Sergey Kornilov admin 2/15/2012 |
John, |
![]() |
lefty author 2/16/2012 |
John, your understanding is not 100% correct. You are trying to fix the query that was correct. In short, when you are working with numeric fields (in update statement or in WHERE clause) do not use single quotes. When you are working with text or date fields do use single quotes.
|