-- ================================================================================================================
-- Stored Procedures generated by LLBLGen v1.21.2003.712 Final on Mittwoch, 10. Mai 2023, 18:42:06
-- For the Low Level Business Logic Layer for the database 'bea_20210830'
-- ================================================================================================================
SET NOCOUNT ON
GO
USE [bea_20210830]
GO

-- ========================================================================================================
-- [Stored Procedures generated for table:  Personal]
GO

-- //// Insert Stored procedure.
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[pr_Personal_Insert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) drop procedure [dbo].[pr_Personal_Insert]
GO

---------------------------------------------------------------------------------
-- Stored procedure that will insert 1 row in the table 'Personal'
-- Gets: @iPersonalnr int
-- Gets: @iParentID int
-- Gets: @sBezeichnung varchar(255)
-- Gets: @sBeschreibung varchar(255)
-- Gets: @sTGNummer varchar(255)
-- Gets: @sName varchar(255)
-- Gets: @iSequenz int
-- Gets: @bAktiv bit
-- Gets: @daErstellt_am datetime
-- Gets: @daMutiert_am datetime
-- Gets: @iMutierer int
-- Gets: @sVerantwTKBMA varchar(255)
-- Gets: @sNextControlDate varchar(255)
-- Gets: @sEMail varchar(255)
-- Gets: @sHauptnutzer varchar(255)
-- Returns: @iErrorCode int
---------------------------------------------------------------------------------
CREATE PROCEDURE [dbo].[pr_Personal_Insert]
	@iPersonalnr int,
	@iParentID int,
	@sBezeichnung varchar(255),
	@sBeschreibung varchar(255),
	@sTGNummer varchar(255),
	@sName varchar(255),
	@iSequenz int,
	@bAktiv bit,
	@daErstellt_am datetime,
	@daMutiert_am datetime,
	@iMutierer int,
	@sVerantwTKBMA varchar(255),
	@sNextControlDate varchar(255),
	@sEMail varchar(255),
	@sHauptnutzer varchar(255),
	@iErrorCode int OUTPUT
AS
SET NOCOUNT ON
-- INSERT a new row in the table.
INSERT [dbo].[Personal]
(
	[Personalnr],
	[ParentID],
	[Bezeichnung],
	[Beschreibung],
	[TGNummer],
	[Name],
	[Sequenz],
	[Aktiv],
	[Erstellt_am],
	[Mutiert_am],
	[Mutierer],
	[VerantwTKBMA],
	[NextControlDate],
	[EMail],
	[Hauptnutzer]
)
VALUES
(
	@iPersonalnr,
	@iParentID,
	@sBezeichnung,
	@sBeschreibung,
	@sTGNummer,
	@sName,
	@iSequenz,
	@bAktiv,
	@daErstellt_am,
	@daMutiert_am,
	@iMutierer,
	@sVerantwTKBMA,
	@sNextControlDate,
	@sEMail,
	@sHauptnutzer
)
-- Get the Error Code for the statement just executed.
SELECT @iErrorCode=@@ERROR
GO


-- //// Update Stored procedure for updating one single row.
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[pr_Personal_Update]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) drop procedure [dbo].[pr_Personal_Update]
GO

---------------------------------------------------------------------------------
-- Stored procedure that will update an existing row in the table 'Personal'
-- Gets: @iPersonalnr int
-- Gets: @iParentID int
-- Gets: @sBezeichnung varchar(255)
-- Gets: @sBeschreibung varchar(255)
-- Gets: @sTGNummer varchar(255)
-- Gets: @sName varchar(255)
-- Gets: @iSequenz int
-- Gets: @bAktiv bit
-- Gets: @daErstellt_am datetime
-- Gets: @daMutiert_am datetime
-- Gets: @iMutierer int
-- Gets: @sVerantwTKBMA varchar(255)
-- Gets: @sNextControlDate varchar(255)
-- Gets: @sEMail varchar(255)
-- Gets: @sHauptnutzer varchar(255)
-- Returns: @iErrorCode int
---------------------------------------------------------------------------------
CREATE PROCEDURE [dbo].[pr_Personal_Update]
	@iPersonalnr int,
	@iParentID int,
	@sBezeichnung varchar(255),
	@sBeschreibung varchar(255),
	@sTGNummer varchar(255),
	@sName varchar(255),
	@iSequenz int,
	@bAktiv bit,
	@daErstellt_am datetime,
	@daMutiert_am datetime,
	@iMutierer int,
	@sVerantwTKBMA varchar(255),
	@sNextControlDate varchar(255),
	@sEMail varchar(255),
	@sHauptnutzer varchar(255),
	@iErrorCode int OUTPUT
AS
SET NOCOUNT ON
-- UPDATE an existing row in the table.
UPDATE [dbo].[Personal]
SET 
	[ParentID] = @iParentID,
	[Bezeichnung] = @sBezeichnung,
	[Beschreibung] = @sBeschreibung,
	[TGNummer] = @sTGNummer,
	[Name] = @sName,
	[Sequenz] = @iSequenz,
	[Aktiv] = @bAktiv,
	[Erstellt_am] = @daErstellt_am,
	[Mutiert_am] = @daMutiert_am,
	[Mutierer] = @iMutierer,
	[VerantwTKBMA] = @sVerantwTKBMA,
	[NextControlDate] = @sNextControlDate,
	[EMail] = @sEMail,
	[Hauptnutzer] = @sHauptnutzer
WHERE
	[Personalnr] = @iPersonalnr
-- Get the Error Code for the statement just executed.
SELECT @iErrorCode=@@ERROR
GO


-- //// Delete Stored procedure using Primary Key.
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[pr_Personal_Delete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) drop procedure [dbo].[pr_Personal_Delete]
GO

---------------------------------------------------------------------------------
-- Stored procedure that will delete an existing row from the table 'Personal'
-- using the Primary Key. 
-- Gets: @iPersonalnr int
-- Returns: @iErrorCode int
---------------------------------------------------------------------------------
CREATE PROCEDURE [dbo].[pr_Personal_Delete]
	@iPersonalnr int,
	@iErrorCode int OUTPUT
AS
SET NOCOUNT ON
-- DELETE an existing row from the table.
DELETE FROM [dbo].[Personal]
WHERE
	[Personalnr] = @iPersonalnr
-- Get the Error Code for the statement just executed.
SELECT @iErrorCode=@@ERROR
GO


-- //// Select Stored procedure, based on Primary Key.
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[pr_Personal_SelectOne]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) drop procedure [dbo].[pr_Personal_SelectOne]
GO

---------------------------------------------------------------------------------
-- Stored procedure that will select an existing row from the table 'Personal'
-- based on the Primary Key.
-- Gets: @iPersonalnr int
-- Returns: @iErrorCode int
---------------------------------------------------------------------------------
CREATE PROCEDURE [dbo].[pr_Personal_SelectOne]
	@iPersonalnr int,
	@iErrorCode int OUTPUT
AS
SET NOCOUNT ON
-- SELECT an existing row from the table.
SELECT
	[Personalnr],
	[ParentID],
	[Bezeichnung],
	[Beschreibung],
	[TGNummer],
	[Name],
	[Sequenz],
	[Aktiv],
	[Erstellt_am],
	[Mutiert_am],
	[Mutierer],
	[VerantwTKBMA],
	[NextControlDate],
	[EMail],
	[Hauptnutzer]
FROM [dbo].[Personal]
WHERE
	[Personalnr] = @iPersonalnr
-- Get the Error Code for the statement just executed.
SELECT @iErrorCode=@@ERROR
GO


-- //// Select All Stored procedure.
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[pr_Personal_SelectAll]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) drop procedure [dbo].[pr_Personal_SelectAll]
GO

---------------------------------------------------------------------------------
-- Stored procedure that will select all rows from the table 'Personal'
-- Returns: @iErrorCode int
---------------------------------------------------------------------------------
CREATE PROCEDURE [dbo].[pr_Personal_SelectAll]
	@iErrorCode int OUTPUT
AS
SET NOCOUNT ON
-- SELECT all rows from the table.
SELECT
	[Personalnr],
	[ParentID],
	[Bezeichnung],
	[Beschreibung],
	[TGNummer],
	[Name],
	[Sequenz],
	[Aktiv],
	[Erstellt_am],
	[Mutiert_am],
	[Mutierer],
	[VerantwTKBMA],
	[NextControlDate],
	[EMail],
	[Hauptnutzer]
FROM [dbo].[Personal]
ORDER BY 
	[Personalnr] ASC
-- Get the Error Code for the statement just executed.
SELECT @iErrorCode=@@ERROR
GO


-- [End of Stored Procedures for table:     Personal]
-- ========================================================================================================
GO
