i have stored procedure in sql server take parameter user_id
i need to check permission for user_id for specific query concept
i need to pass user_id parameter and check if this user exists on query result or not
if it is exists the stored will return 1 else the stored will return 0
so if result = 1 meaning that the user has permission i want else i will prevent him to complete action in my code side.
the stored Procedure Sample Code
declare @valback int;
exec @valback = VACATION_REPORTS_REQUEST_GET_USER_STAGE_PERMISSION 10,1,1;
SELECT @valback;
i need to check permission for user_id for specific query concept
i need to pass user_id parameter and check if this user exists on query result or not
if it is exists the stored will return 1 else the stored will return 0
so if result = 1 meaning that the user has permission i want else i will prevent him to complete action in my code side.
the stored Procedure Sample Code
USE [HES_Intranet]GO/****** Object: StoredProcedure [dbo].[VACATION_REPORTS_REQUEST_GET_SENT_COUNT] Script Date: 03/23/2014 01:49:24 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER PROC [dbo].[VACATION_REPORTS_REQUEST_GET_USER_STAGE_PERMISSION]@USER_ID INT ,@POSITION_ID INT ,@STAGE_ID INT ,@WORK_FLOW_ID INTASBEGINSET NOCOUNT ONSET XACT_ABORT ON/*THE IF STATEMENT CHECK IF 1 IS SELECTED THIS MEANING THAT THEUSER_ID PASSED EXISTS ON SELECT PERMISSION QUERYELSE MEANING THAT THAT USER POSITION NOT ALLOWED TO LOGIN AND ALSONO PERMISSION FOR WORKFLOW GAVEN TO HIM BY SYSTEM ADMIN */IF((SELECT 1WHERE @USER_ID IN ( select USER_ID from USERS U where U.POSITION_ID=@POSITION_IDunionselect USER_ID from USER_ROLES UR
the Stored Procedure Call Test in sql server Sidewhere ur.WORK_FLOW_ID=@WORK_FLOW_IDAND UR.REQUEST_STAGE_ID=@STAGE_ID)) =1)RETURN 1ELSERETURN 0;END
declare @valback int;
exec @valback = VACATION_REPORTS_REQUEST_GET_USER_STAGE_PERMISSION 10,1,1;
SELECT @valback;
No comments:
Post a Comment