on 07-18-2012 8:52 PM
Estimados,
Con respecto al transactio notification tengo las siguientes preguntas:
1- Cuando se modifica el SP Transaction Notification y deseo agregar varias validaciones, es necesario en cada validación cambiar el valor de Set @Error
2- Que orden sigue el validador
3- En algunos casos en mi SP de Transaction Notification he notado que alguna validación no la cumple
4- Al finalizar de todas mis validaciones coloco:
select @error, @error_message
End
Muchas Gracias por el tiempo compartido.
Muchas Gracias Felipe
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Estimado
Respondiendo sus preguntas.
1: Valor por defecto del error del Transaction es 0, porque el 0 es igual a "NO ERROR", para que la validación sea efectiva el parámetro @error debe tener un valor distinto a 0.
Para colocar múltiples validaciones
/****** Object: StoredProcedure [dbo].[SBO_SP_TransactionNotification] Script Date: 07/18/2012 16:43:09 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[SBO_SP_TransactionNotification]
@object_type nvarchar(20), -- SBO Object Type
@transaction_type nchar(1), -- [A]dd, [U]pdate, [D]elete, [C]ancel, C[L]ose
@num_of_cols_in_key int,
@list_of_key_cols_tab_del nvarchar(255),
@list_of_cols_val_tab_del nvarchar(255)
AS
begin
-- Return values
declare @error int -- Result (0 for no error)
declare @error_message nvarchar (200) -- Error string to be displayed
select @error = 0
select @error_message = N'Ok'
--------------------------------------------------------------------------------------------------------------------------------
-- ADD YOUR CODE HERE
-- VALIDACION 1
IF @object_type=X AND @transaction_type=Y
BEGIN
VALIDACION
BEGIN
SELECT @error=1000, @error_message='error 1000'
END
END
-- VALIDACION 2
IF @object_type=X AND @transaction_type=Y
BEGIN
VALIDACION
BEGIN
SELECT @error=2000, @error_message='error 2000'
END
END
ETC
ETC
ETC
--------------------------------------------------------------------------------------------------------------------------------
-- Select the return values
select @error, @error_message
end
2 No estoy seguro del orden pero debe ser desde arriba hacia abajo hasta que encuentre algo que dispare la validacion
3 Si no la cumple, hay algo malo dentro de la validacion
4 Eso es solo para el final de todo el stored procedure
Saludos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
109 | |
15 | |
10 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.