-- ================================================================================================================
-- Stored Procedures generated by LLBLGen v1.21.2003.712 Final on Mittwoch, 23. Januar 2013, 12:54:32
-- For the Low Level Business Logic Layer for the database 'themenmanagement'
-- ================================================================================================================
SET NOCOUNT ON
GO
USE [themenmanagement]
GO

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

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

---------------------------------------------------------------------------------
-- Stored procedure that will insert 1 row in the table 'Kategorie'
-- Gets: @iKategorieNr int
-- Gets: @iParentid int
-- Gets: @sBezeichnung varchar(255)
-- Gets: @sBeschreibung varchar(1024)
-- Gets: @baktiv bit
-- Gets: @daerstellt_am datetime
-- Gets: @damutiert_am datetime
-- Gets: @imutierer int
-- Returns: @iErrorCode int
---------------------------------------------------------------------------------
CREATE PROCEDURE [dbo].[pr_Kategorie_Insert]
	@iKategorieNr int,
	@iParentid int,
	@sBezeichnung varchar(255),
	@sBeschreibung varchar(1024),
	@baktiv bit,
	@daerstellt_am datetime,
	@damutiert_am datetime,
	@imutierer int,
	@iErrorCode int OUTPUT
AS
SET NOCOUNT ON
-- INSERT a new row in the table.
INSERT [dbo].[Kategorie]
(
	[KategorieNr],
	[Parentid],
	[Bezeichnung],
	[Beschreibung],
	[aktiv],
	[erstellt_am],
	[mutiert_am],
	[mutierer]
)
VALUES
(
	@iKategorieNr,
	@iParentid,
	@sBezeichnung,
	@sBeschreibung,
	@baktiv,
	@daerstellt_am,
	@damutiert_am,
	@imutierer
)
-- 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_Kategorie_Update]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) drop procedure [dbo].[pr_Kategorie_Update]
GO

---------------------------------------------------------------------------------
-- Stored procedure that will update an existing row in the table 'Kategorie'
-- Gets: @iKategorieNr int
-- Gets: @iParentid int
-- Gets: @sBezeichnung varchar(255)
-- Gets: @sBeschreibung varchar(1024)
-- Gets: @baktiv bit
-- Gets: @daerstellt_am datetime
-- Gets: @damutiert_am datetime
-- Gets: @imutierer int
-- Returns: @iErrorCode int
---------------------------------------------------------------------------------
CREATE PROCEDURE [dbo].[pr_Kategorie_Update]
	@iKategorieNr int,
	@iParentid int,
	@sBezeichnung varchar(255),
	@sBeschreibung varchar(1024),
	@baktiv bit,
	@daerstellt_am datetime,
	@damutiert_am datetime,
	@imutierer int,
	@iErrorCode int OUTPUT
AS
SET NOCOUNT ON
-- UPDATE an existing row in the table.
UPDATE [dbo].[Kategorie]
SET 
	[Parentid] = @iParentid,
	[Bezeichnung] = @sBezeichnung,
	[Beschreibung] = @sBeschreibung,
	[aktiv] = @baktiv,
	[erstellt_am] = @daerstellt_am,
	[mutiert_am] = @damutiert_am,
	[mutierer] = @imutierer
WHERE
	[KategorieNr] = @iKategorieNr
-- 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_Kategorie_Delete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) drop procedure [dbo].[pr_Kategorie_Delete]
GO

---------------------------------------------------------------------------------
-- Stored procedure that will delete an existing row from the table 'Kategorie'
-- using the Primary Key. 
-- Gets: @iKategorieNr int
-- Returns: @iErrorCode int
---------------------------------------------------------------------------------
CREATE PROCEDURE [dbo].[pr_Kategorie_Delete]
	@iKategorieNr int,
	@iErrorCode int OUTPUT
AS
SET NOCOUNT ON
-- DELETE an existing row from the table.
DELETE FROM [dbo].[Kategorie]
WHERE
	[KategorieNr] = @iKategorieNr
-- 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_Kategorie_SelectOne]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) drop procedure [dbo].[pr_Kategorie_SelectOne]
GO

---------------------------------------------------------------------------------
-- Stored procedure that will select an existing row from the table 'Kategorie'
-- based on the Primary Key.
-- Gets: @iKategorieNr int
-- Returns: @iErrorCode int
---------------------------------------------------------------------------------
CREATE PROCEDURE [dbo].[pr_Kategorie_SelectOne]
	@iKategorieNr int,
	@iErrorCode int OUTPUT
AS
SET NOCOUNT ON
-- SELECT an existing row from the table.
SELECT
	[KategorieNr],
	[Parentid],
	[Bezeichnung],
	[Beschreibung],
	[aktiv],
	[erstellt_am],
	[mutiert_am],
	[mutierer]
FROM [dbo].[Kategorie]
WHERE
	[KategorieNr] = @iKategorieNr
-- 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_Kategorie_SelectAll]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) drop procedure [dbo].[pr_Kategorie_SelectAll]
GO

---------------------------------------------------------------------------------
-- Stored procedure that will select all rows from the table 'Kategorie'
-- Returns: @iErrorCode int
---------------------------------------------------------------------------------
CREATE PROCEDURE [dbo].[pr_Kategorie_SelectAll]
	@iErrorCode int OUTPUT
AS
SET NOCOUNT ON
-- SELECT all rows from the table.
SELECT
	[KategorieNr],
	[Parentid],
	[Bezeichnung],
	[Beschreibung],
	[aktiv],
	[erstellt_am],
	[mutiert_am],
	[mutierer]
FROM [dbo].[Kategorie]
ORDER BY 
	[KategorieNr] ASC
-- Get the Error Code for the statement just executed.
SELECT @iErrorCode=@@ERROR
GO


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