This topic is locked
[SOLVED]

 sql table with calculated field

4/9/2020 11:12:40 AM
PHPRunner General questions
J
jacktonghk authorDevClub member

I have a table in SQLServer in which there is a calculated field item_total defined as item_unit_cost * item_qty. I tried to use the table directly but I have got an update error in the add/edit page event saying that item_total is not allowed to update (because it is a calculated field). Because I want then item_total to be displayed on the add/edit page, My workaround is to create a custom view from my original table and added the calculated field dynamically in the SQL select statement.
My questions are

  1. Is there any way that I can use the original table without error? ie. when doing updating, PHP runner can skip the calculated field
  2. What is the difference between a custom view and SQL view
    Thanks

N
Nir Frumer 4/9/2020

hi

you probably don't need the calculated field on the add/edit pages

otherwise,

remove it from the add/update array in the before add/ before update,

in phprunner it will be:
unset['item_total'];
or its equivalent on ASP...
hope it helps,

A
AlphaBase 4/9/2020

To add to that, here is a link: Unset

J
jacktonghk authorDevClub member 4/9/2020

It works!! Thank you.