Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update Multiple Fields Single Case

Status
Not open for further replies.

CptTom

Programmer
Jul 16, 2001
117
US
I want to update multiple fields off a single Case (or IF) statement.

Example
Update Temp_AMSS
If DIC <> 'XM'
begin
Set Errors = 'Wrong Report'
Set RejectErrors = RejectErrors + 1
end
end
If next query
Begin
Set Errors = Errors + ' next Error'
Set RejectErrors = RejectErrors + 1
End
End

Larry
 
Your example is incomprehensible. What is DIC and what do you mean by if next query?

Could you provide some more details.
 
DIC is a field which will act as the qualifier for a query and Next Query means I will run several of these. If I can get the first one working, then I can repeat it as often as necessary.
 
Do you mean something like this:

Code:
UPDATE temp_amss
SET errors =
  CASE
    WHEN dic <> 'xm' THEN 'wrong report'
    WHEN dic <> 'abc' THEN 'bad report'
    ELSE errors + ' next error'
  END,
  rejecterrors = rejecterrors + 1

--James
 
Yes but...
I am trying to keep a running count of errors, so I have 2 fields, KeepErrors & RejectErrors. So, when an error occurs, then I update 2 fields, Errors and the appropriate error count field.

So, it would be something like:

Case DIC <> 'XM'
update error = 'Not XM Record'
update rejecterrors = 1
End
Case Month(Date_Reported) is wrong
update errors = errors + ' Wrong Report Month'
update rejecterrors = rejecterrors = 1
End
Case Date(Date_Reported) is wrong
update errors = errors + ' Wrong Report Month'
update keeperrors = keeperrors = 1
End
And so forth...

Larry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top