on 08-16-2010 3:27 PM
Tengo el siguiente codigo que utilizo en el TransactionNotification para que cuando un usuario cambio el campo u_ubicacion en una tabla definida por el usuario actualice ese campo en la OITM. Pero tengo el problema que si el usuario digita mal el itemcode dentro de esa tabla definida, no me lo valida. Necesito que alguien me oriente para donde poner esa validacion dentro del transaction. Que si el itemcode no exista me mande un error.
If @object_type='TM01' and @transaction_type in ('A','U') Begin
Update OITM
set u_ubicacion=t0.u_ubicacion
from @TMUBICACION T0 where t0.u_itemcode = itemcode
end
SD
Mete ese itemcode (el que viene de una tabla de usuario) en un
if @itemcode not in (select itemcode from oitm)
te mande el error
asi podrias validarlo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Tengo estas dos validaciones, se supone que la primera me indica si el item existe y si no me mande mensje de error; y la segunda, que me actualice la OITM cuando capturo la ubicacion en una tabla definida por el usuario.
Primero: Orientarme para saber si esta bien
Segundo: como puedo unir las dos para que quede en una sola validacion
IF (@transaction_type = 'A' or @transaction_type = 'U') AND @object_type = 'TM01'
BEGIN
if not exists (Select Distinct (T1.ItemCode) from OITM T1 INNER JOIN [@TMUBICACION] T0
ON T1.ItemCode = T0.u_ItemCode
where (T0.u_itemcode = @list_of_cols_val_tab_del))
begin
SELECT @error = 1, @error_message = 'No puedes modificar este articulo porque no existe!'
end
END
IF (@transaction_type = 'A' or @transaction_type = 'U') AND @object_type = 'TM01'
BEGIN
if exists (Select Distinct (T1.ItemCode) from OITM T1 INNER JOIN [@TMUBICACION] T0
ON T1.ItemCode = T0.u_ItemCode
where (T0.u_itemcode = @list_of_cols_val_tab_del))
begin
Update OITM
set u_ubicacion=t0.u_ubicacion
from [@TMUBICACION] T0 where t0.u_itemcode = itemcode
end
END
User | Count |
---|---|
97 | |
9 | |
8 | |
6 | |
3 | |
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.