Skip to Content
author's profile photo Former Member
Former Member

Ayuda con Transaction Notification

Buenos días

Tengo el siguiente código en TransactionNotification para enviar un mensaje de error si existe un número de parte duplicado en una orden de venta

-- Busca duplicados en orden de venta

if (@Object_type in ('17') and @transaction_type in('A')) OR (@Object_type in ('17')

and @transaction_type in('U'))

begin

declare @duplicado as nvarchar(8)

set @duplicado = (SELECT COUNT(T0.ItemCOde) FROM RDR1 T0 INNER JOIN ORDR T1 ON T0.DocEntry = T1.DocEntry

WHERE T0.DocEntry = @list_of_cols_val_tab_del GROUP BY (T0.ItemCode) HAVING ( COUNT(T0.ItemCode) > 1 ))

IF len( @duplicado)> 0

begin

SET @error = 1

SET @error_message = ('ERROR existe uno o mas items repetidos en orden de venta ')

end

end

-- Termina rutina de búsqueda de duplicados

Funciona bien si hay un renglón duplicado pero si hay más de un número de parte duplicado marca el error de

"Subquery returned more than 1 value"

¿Me pueden ayudar a depurar la condición?

Gracias de antemano

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Oct 12, 2010 at 07:51 PM

    Porque no intentas colocando un Top 1 en tu subquery?

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.