April 3, 2008 at 9:45 am
I have some validation that I want to perform. I pass in some permission information ( a bit) and some employeeids. What I want is, if the bit =1 to continue on if it is equal to 0 then I want the validation to procedure down to the a codeblock that validates the current user is a manager(this validation I have figured I just need to know how I can jump to certain code blocks and skip them based on that bit. Does anyone have any suggestions?
thanks
April 3, 2008 at 9:56 am
Not 100% sure what you're asking here, but...
CREATE PROCEDURE IS_MGR
@STATUSFLG Bit
AS
IF (@STATUSFLG = 1)
BEGIN
(... Put Code Here...)
END
ELSE
BEGIN
(... Put Code Here...)
END
[/CODE]
April 3, 2008 at 10:55 am
So to clear things up I have a param @mgrFlag that captures the permission from the app.
Orginailly I had this:
If not exists(select 1 from EmployeeAssocTable where EmployeeID = @EnteredForEmpID and AuthorizeEmployeeID = @EnteredByEmpID)
begin
Raiserror('The current user is not a manager for this employee.',16,1)
end
so if the record doesn't exist it raises an error. What I want to do is check the override flag (the permission is to allow the current user to approve any payroll). If its one, then skip the validation up top. if it is 0 perform that validation
April 3, 2008 at 11:05 am
tthellebuyck (4/3/2008)
So to clear things up I have a param @mgrFlag that captures the permission from the app.Orginailly I had this:
If not exists(select 1 from EmployeeAssocTable where EmployeeID = @EnteredForEmpID and AuthorizeEmployeeID = @EnteredByEmpID)
begin
Raiserror('The current user is not a manager for this employee.',16,1)
end
so if the record doesn't exist it raises an error. What I want to do is check the override flag (the permission is to allow the current user to approve any payroll). If its one, then skip the validation up top. if it is 0 perform that validation
Changes in bold should give you what you need:
If (not exists(select 1 from EmployeeAssocTable where EmployeeID = @EnteredForEmpID and AuthorizeEmployeeID = @EnteredByEmpID))
or @mgrFlag = 1
begin
Raiserror('The current user is not a manager for this employee.',16,1)
end
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply