|
if exists (select * from dbo.sysobjects where id = object_id(N'[MaintenanceReference]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [MaintenanceReference]
GO
CREATE TABLE [MaintenanceReference](
[Id] NVarChar(36) NOT NULL
,[MaintenanceScheduleId] NVarChar(36) NOT NULL
,[Notes] NVarChar(36) NOT NULL
)
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[MaintenanceReference_Create]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[MaintenanceReference_Create]
GO
--- <summary>
--- Maintenance Reference_Create
--- </summary>
CREATE PROCEDURE MaintenanceReference_Create
(
@Id NVarChar(36)
,@MaintenanceScheduleId NVarChar(36)
,@Notes NVarChar(36)
)
AS
SET NOCOUNT ON
DECLARE @ReturnCode INT
BEGIN TRANSACTION
INSERT INTO [MaintenanceReference](
[Id]
,[MaintenanceScheduleId]
,[Notes]
)
VALUES(
@Id
,@MaintenanceScheduleId
,@Notes
)
-- ERROR CHECK
SELECT @ReturnCode = @@ERROR
IF @ReturnCode <> 0 GOTO ErrorHandeler
-- Commit if no Errors
COMMIT TRANSACTION
RETURN @ReturnCode
-- Rollback if Errors
ErrorHandeler:
ROLLBACK TRANSACTION
RETURN @ReturnCode
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[MaintenanceReference_Update]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[MaintenanceReference_Update]
GO
--- <summary>
--- Maintenance Reference_Update
--- </summary>
CREATE PROCEDURE MaintenanceReference_Update
(
@Id NVarChar(36)
,@MaintenanceScheduleId NVarChar(36)
,@Notes NVarChar(36)
)
AS
SET NOCOUNT ON
DECLARE @ReturnCode INT
BEGIN TRANSACTION
UPDATE [MaintenanceReference] SET
[Id] = @Id
,[MaintenanceScheduleId] = @MaintenanceScheduleId
,[Notes] = @Notes
WHERE
[MaintenanceReference].Id = @Id
-- ERROR CHECK
SELECT @ReturnCode = @@ERROR
IF @ReturnCode <> 0 GOTO ErrorHandeler
-- Commit if no Errors
COMMIT TRANSACTION
RETURN @ReturnCode
-- Rollback if Errors
ErrorHandeler:
ROLLBACK TRANSACTION
RETURN @ReturnCode
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[MaintenanceReference_Delete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[MaintenanceReference_Delete]
GO
--- <summary>
--- Maintenance Reference_Delete
--- </summary>
CREATE PROCEDURE MaintenanceReference_Delete
(
@Id NvarChar(36)
)
AS
SET NOCOUNT ON
DECLARE @ReturnCode INT
BEGIN TRANSACTION
DELETE
[MaintenanceReference]
WHERE
[MaintenanceReference].Id = @Id
-- ERROR CHECK
SELECT @ReturnCode = @@ERROR
IF @ReturnCode <> 0 GOTO ErrorHandeler
-- Commit if no Errors
COMMIT TRANSACTION
RETURN @ReturnCode
-- Rollback if Errors
ErrorHandeler:
ROLLBACK TRANSACTION
RETURN @ReturnCode
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[MaintenanceReference_Fetch]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[MaintenanceReference_Fetch]
GO
--- <summary>
--- Maintenance Reference_Fetch
--- </summary>
CREATE PROCEDURE MaintenanceReference_Fetch
(
@Id NvarChar(36)
)
AS
SET NOCOUNT ON
SELECT
[Id]
,[MaintenanceScheduleId]
,[Notes]
FROM
[MaintenanceReference] WITH (NOLOCK)
WHERE
[MaintenanceReference].Id = @Id
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[MaintenanceReference_FetchByMaintenanceScheduleId') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[MaintenanceReference_FetchByMaintenanceScheduleId]
GO
--- <summary>
--- MaintenanceReference_FetchByMaintenanceScheduleId
--- </summary>
CREATE PROCEDURE MaintenanceReference_FetchByMaintenanceScheduleId
(
@MaintenanceScheduleId NvarChar(36)
)
AS
SET NOCOUNT ON
SELECT
[Id]
,[MaintenanceScheduleId]
,[Notes]
FROM
[MaintenanceReference] WITH (NOLOCK)
WHERE
[MaintenanceReference].MaintenanceScheduleId = @MaintenanceScheduleId
GO
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Software Architect with 20++ years of software design and development experience with a strong hold in Object-Oriented software engineering using UML with Design Patterns. Architected and developed several industrial software packages and passed through full software development life-cycle. Currently managing a small group of developers, developing management software for the agriculture industry.