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

Evitar duplicidad de datos

hola a todos,

ayuda en la validacion del campo referencia de la OINV,,,para que no dupliquen o no se repitan los valores (datos)

yo lo hice de esta manera:

pero no esta validando correctamente...

if @object_type = '13' and (@transaction_type = 'A' or @transaction_type = 'U')

BEGIN

declare @numref as varchar(100)

declare @ref as int

set @ref = 0

set @numref = (Select x.NumAtCard from OINV x where x.DocEntry=@list_of_cols_val_tab_del)

set @ref = (select count(xx.NumAtCard)from OINV xx where upper(xx.NumAtCard)=upper(@numref))

set @ref=@ref - 1

if @ref >= 0 or @numref is null

begin

set @error='9998'

set @error_message='El Número de Nota de Remisión [ '+@numref+' ] ya existe o esta en blanco, favor verificar '+CAST(@ref as varchar(10))

end

END

de antemano les agradezco su valiosa ayuda.

atte: Edwin

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Mar 11, 2013 at 09:08 PM

    Ve si te sirve de esta manera,

    if @object_type = '13' and (@transaction_type in ('A' ,'U'))begindeclare @Numref as varchar (100)if (@object_type = '13')beginselect @Numref = NumAtCard from OINV T0 where docentry = @list_of_cols_Val_tab_delbeginif (@Numref is not null) or (@Numref is null)beginif 1!= (select count (docentry) from OINV  where (NumatCard = @Numref) )beginselect @error =9998select @error_message = 'El Número de Nota de Remisión ['+@Numref+'] ya existe o esta en blanco, favor verificar'EndEndEndEndEnd

    Saludos.

    Alessandro.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 06, 2013 at 02:03 PM

    Hubiera sido más fácil creo yo habilitando la opción de bloquear referencia del cilente en Gestión - Inicialización sistema - Parametrizaciones de documento, pestaña Por Documento, y ahí elijes Factura y luego elijes "Blo&quear liberación/recibo" en la sección de "Si se produce un duplicado del número de referencia del cliente".

    Saludos,

    Juan Carlos.

    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.