Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
7| Name | Data Type | Length | Description |
|---|---|---|---|
| @accion | varchar | 20 | |
| @idfaq | int | 4 | |
| @question | varchar | 200 | |
| @answer | text | -1 | |
| @activo | bit | 1 | |
| @created_by | int | 4 | |
| @modified_by | int | 4 |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE OR ALTER PROCEDURE dbo.abm_faq
@accion varchar(20), /* selectall / agregar / editar / actualizar / search */
@idfaq int = NULL,
@question VARCHAR(200) = NULL,
@answer TEXT = NULL,
@activo BIT = 1,
@created_by INT = NULL,
@modified_by INT = NULL
AS
BEGIN
SET NOCOUNT ON;
SET @accion=upper(@accion)
DECLARE @idFaqCreated INT = NULL
IF @accion = 'AGREGAR'
BEGIN
if @question is not null and @answer is not null and @created_by is not null
BEGIN
insert into faq (question,answer,created_by) values (@question,@answer,@created_by)
SELECT @idFaqCreated = @@identity
RETURN @idFaqCreated
END
end
IF @accion = 'ACTUALIZAR' AND (@question is not null and @answer is not null and @created_by is not null AND @idfaq IS NOT null)
BEGIN
UPDATE faq SET question =@question,answer =@answer, modified_by = @modified_by,activo = @activo WHERE idfaq=@idfaq
end
if @accion = 'SEARCH' AND @question is not null
BEGIN
SELECT * FROM faq WHERE question LIKE '%' + @question + '%' order BY question ASC
END
IF @accion = 'SELECTALL'
BEGIN
SELECT * FROM faq order BY question ASC
END
IF @accion = 'EDITAR' AND (@idfaq IS NOT null)
BEGIN
SELECT * FROM faq WHERE idfaq=@idfaq
END
END
GO
GO
CREATE OR ALTER PROCEDURE dbo.abm_faq
@accion varchar(20), /* selectall / agregar / editar / actualizar / search */
@idfaq int = NULL,
@question VARCHAR(200) = NULL,
@answer TEXT = NULL,
@activo BIT = 1,
@created_by INT = NULL,
@modified_by INT = NULL
AS
BEGIN
SET NOCOUNT ON;
SET @accion=upper(@accion)
DECLARE @idFaqCreated INT = NULL
IF @accion = 'AGREGAR'
BEGIN
if @question is not null and @answer is not null and @created_by is not null
BEGIN
insert into faq (question,answer,created_by) values (@question,@answer,@created_by)
SELECT @idFaqCreated = @@identity
RETURN @idFaqCreated
END
end
IF @accion = 'ACTUALIZAR' AND (@question is not null and @answer is not null and @created_by is not null AND @idfaq IS NOT null)
BEGIN
UPDATE faq SET question =@question,answer =@answer, modified_by = @modified_by,activo = @activo WHERE idfaq=@idfaq
end
if @accion = 'SEARCH' AND @question is not null
BEGIN
SELECT * FROM faq WHERE question LIKE '%' + @question + '%' order BY question ASC
END
IF @accion = 'SELECTALL'
BEGIN
SELECT * FROM faq order BY question ASC
END
IF @accion = 'EDITAR' AND (@idfaq IS NOT null)
BEGIN
SELECT * FROM faq WHERE idfaq=@idfaq
END
END
GO
Depends On
1Used By
No items found