Summary Table

Categories Total Count
PII 0
URL 0
DNS 0
EKL 0
IP 0
PORT 0
VsID 0
CF 0
AI 0
VPD 0
PL 0
Other 0

File Content

?-- =============================================
-- Description: Returns Station Details.
-- Maintenance Log:
--
-- Update By Update Date Description
-- ----------- --------- ----------------------------
-- =============================================
CREATE PROCEDURE [dbo].[uspRptStationDetails]
-- Add the parameters for the stored procedure here
@visnIds varchar(max),
@stationIds varchar(max),
@userId int

AS
DECLARE @stationsTable TABLE
(
RowID int,
ModuleID tinyint,
VisnID tinyint,
StationID smallint,
ParentStationID smallint,
Station3N varchar(10),
Station6A varchar(10),
StationDisplayName varchar(100),
StationName varchar(100),
IsParent bit,
Inactive bit
)

BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

BEGIN TRY
--populate what stations the user has permission to see
INSERT INTO @stationsTable (RowID, ModuleID, VisnID, StationID, ParentStationID, Station3N, Station6A
, StationDisplayName, StationName, IsParent, Inactive)
EXEC seclyr.uspGetUserStations @userId, NULL;

SELECT
Visns.VisnCode
, ParentStations.Station3N AS ParentStation3N
, Stations.StationID
, Stations.Station3N
, Stations.Station6A
, Stations.Moniker
, Stations.StationName
, Stations.VisnID
, Stations.DisplayName
, Stations.ParentStation
, Stations.Inactive
, Stations.DateInactive
FROM Stations
LEFT OUTER JOIN Stations ParentStations ON Stations.ParentStationID = ParentStations.StationID
INNER JOIN Visns ON Visns.VisnID = Stations.VisnID
LEFT OUTER JOIN @stationsTable sx ON Stations.StationID = sx.StationID
WHERE (ISNULL(Stations.VisnID, 0) In(SELECT [Value] FROM ufnSplit(',', @visnIds)) OR @visnIds IS NULL)
AND (ISNULL(Stations.ParentStationID, 0) In(SELECT [Value] FROM ufnSplit(',', @stationIds)) OR @stationIds IS NULL)
ORDER BY Visns.VisnID, Stations.StationID, Stations.Station3N, Stations.Station6A
;
END TRY

BEGIN CATCH
PRINT 'There was an error processing the Stations Details' + CHAR(13);
SELECT * FROM ufnGetErrorInfo();
EXEC uspRaiseErrorInfo;
END CATCH
END