Glowworm27
Programmer
Hey all,
I am having trouble with an update query. I keep getting an error that the subquery returned more than one value....
I have a claims table(tblClaims), and each claim has a location(tblClaimLocations), and each location has a District Manager(DMTbl). Now in the Claims table we have the "Current District Manager listed" this is based on who is the manager for the location that is in the claim.
There is a one to one match for claims and locations, a one to one match between locations and District managers.
Now I have a page that allows admins to change the district manager in the location, when they are done I set an UPDATED bit field flag in the locations table so that we know which location was changed.
After the admin is done editing locations I will allow them to click a button that will go thru all the claims and change the current DM to the new DM listed in the location.
trouble is I keep getting an error that the subquery returned more than one row... and its frustrating. here is the update query
just one last thing there is a trigger on the claim table that will write a record to the notes field and list the fields that were changed, old value and new value.
George Oakes
Check out this awsome .Net Resource!
I am having trouble with an update query. I keep getting an error that the subquery returned more than one value....
I have a claims table(tblClaims), and each claim has a location(tblClaimLocations), and each location has a District Manager(DMTbl). Now in the Claims table we have the "Current District Manager listed" this is based on who is the manager for the location that is in the claim.
There is a one to one match for claims and locations, a one to one match between locations and District managers.
Now I have a page that allows admins to change the district manager in the location, when they are done I set an UPDATED bit field flag in the locations table so that we know which location was changed.
After the admin is done editing locations I will allow them to click a button that will go thru all the claims and change the current DM to the new DM listed in the location.
trouble is I keep getting an error that the subquery returned more than one row... and its frustrating. here is the update query
Code:
Update tblClaims
Set txtMisc7 = dmtbl.[desc] -- text field of the current DM
from tblClaims C
Inner Join tblClaimLocations L On C.lngLocationID = L.lngLocationID
Inner Join dmtbl on l.txtDistrictMgr = dmtbl.DMID
where l.updated = 1 --location that was changed
and NOT (l.txtDistrictMGR is NUll) --thought this would help with the error, its not helping
and (dmtbl.[desc] <> C.txtmisc7) -- only change the current dm if the two fields are different
just one last thing there is a trigger on the claim table that will write a record to the notes field and list the fields that were changed, old value and new value.
George Oakes
Check out this awsome .Net Resource!