Duplicate() without a unique key 
Author Message
 Duplicate() without a unique key

Has anyone even needed to do this ?

I have a situation where I need to allow duplicate entries but I need to
warn the user when one exists.
Basically I need the Duplicate() functionality but without a unique key.  Is
there a way to achieve this ?

Thanks

Eric Cossettini



Tue, 11 Nov 2003 08:17:33 GMT  
 Duplicate() without a unique key
Hello, Eric.

If you are using a form (and even if you are not) and the field that you
wish to check for is one of the keys, then in the accepted code for the "Ok"
button (or equivalent if not a form), do a Fetch() and if it returns a
LEVEL:Benign, then you know that a record with the target field already
exists.

                            -Ray.


Quote:
> Has anyone even needed to do this ?

> I have a situation where I need to allow duplicate entries but I need to
> warn the user when one exists.
> Basically I need the Duplicate() functionality but without a unique key.
Is
> there a way to achieve this ?

> Thanks

> Eric Cossettini



Tue, 11 Nov 2003 09:05:08 GMT  
 Duplicate() without a unique key
Thanks Ray, but its actually on a form and when I use Fetch it loses the
record that I was on and gives "Record is not available".


Quote:
> Hello, Eric.

> If you are using a form (and even if you are not) and the field that you
> wish to check for is one of the keys, then in the accepted code for the
"Ok"
> button (or equivalent if not a form), do a Fetch() and if it returns a
> LEVEL:Benign, then you know that a record with the target field already
> exists.

>                             -Ray.



> > Has anyone even needed to do this ?

> > I have a situation where I need to allow duplicate entries but I need to
> > warn the user when one exists.
> > Basically I need the Duplicate() functionality but without a unique key.
> Is
> > there a way to achieve this ?

> > Thanks

> > Eric Cossettini



Tue, 11 Nov 2003 09:36:35 GMT  
 Duplicate() without a unique key
Try TryFetch, it doesn't mash the buffer.

--

Steve Parker
[Team Topspeed - Internet Connect]

-------------------------------------------------------------
Knowledge base: www.par2.com/cws/c5launch.dll/faqs/thefaqs.exe.0
Download center: www.par2.com/cws/c5launch.dll/d7.exe.0
--------------------------------------------------------------


Quote:
> Thanks Ray, but its actually on a form and when I use Fetch it loses the
> record that I was on and gives "Record is not available".



> > Hello, Eric.

> > If you are using a form (and even if you are not) and the field that you
> > wish to check for is one of the keys, then in the accepted code for the
> "Ok"
> > button (or equivalent if not a form), do a Fetch() and if it returns a
> > LEVEL:Benign, then you know that a record with the target field already
> > exists.

> >                             -Ray.



> > > Has anyone even needed to do this ?

> > > I have a situation where I need to allow duplicate entries but I need
to
> > > warn the user when one exists.
> > > Basically I need the Duplicate() functionality but without a unique
key.
> > Is
> > > there a way to achieve this ?

> > > Thanks

> > > Eric Cossettini



Tue, 11 Nov 2003 09:58:47 GMT  
 Duplicate() without a unique key
Or use an alias...

Steve Walker


Quote:
> Try TryFetch, it doesn't mash the buffer.

> --

> Steve Parker
> [Team Topspeed - Internet Connect]

> -------------------------------------------------------------
> Knowledge base: www.par2.com/cws/c5launch.dll/faqs/thefaqs.exe.0
> Download center: www.par2.com/cws/c5launch.dll/d7.exe.0
> --------------------------------------------------------------



> > Thanks Ray, but its actually on a form and when I use Fetch it loses the
> > record that I was on and gives "Record is not available".



> > > Hello, Eric.

> > > If you are using a form (and even if you are not) and the field that
you
> > > wish to check for is one of the keys, then in the accepted code for
the
> > "Ok"
> > > button (or equivalent if not a form), do a Fetch() and if it returns a
> > > LEVEL:Benign, then you know that a record with the target field
already
> > > exists.

> > >                             -Ray.



> > > > Has anyone even needed to do this ?

> > > > I have a situation where I need to allow duplicate entries but I
need
> to
> > > > warn the user when one exists.
> > > > Basically I need the Duplicate() functionality but without a unique
> key.
> > > Is
> > > > there a way to achieve this ?

> > > > Thanks

> > > > Eric Cossettini



Tue, 11 Nov 2003 11:17:50 GMT  
 Duplicate() without a unique key
The buffer stays intact but I still get "Record is not available" when I
click OK.  I feel as though I am missing something simple.


Quote:
> Try TryFetch, it doesn't mash the buffer.

> --

> Steve Parker
> [Team Topspeed - Internet Connect]

> -------------------------------------------------------------
> Knowledge base: www.par2.com/cws/c5launch.dll/faqs/thefaqs.exe.0
> Download center: www.par2.com/cws/c5launch.dll/d7.exe.0
> --------------------------------------------------------------



> > Thanks Ray, but its actually on a form and when I use Fetch it loses the
> > record that I was on and gives "Record is not available".



> > > Hello, Eric.

> > > If you are using a form (and even if you are not) and the field that
you
> > > wish to check for is one of the keys, then in the accepted code for
the
> > "Ok"
> > > button (or equivalent if not a form), do a Fetch() and if it returns a
> > > LEVEL:Benign, then you know that a record with the target field
already
> > > exists.

> > >                             -Ray.



> > > > Has anyone even needed to do this ?

> > > > I have a situation where I need to allow duplicate entries but I
need
> to
> > > > warn the user when one exists.
> > > > Basically I need the Duplicate() functionality but without a unique
> key.
> > > Is
> > > > there a way to achieve this ?

> > > > Thanks

> > > > Eric Cossettini



Tue, 11 Nov 2003 11:25:18 GMT  
 Duplicate() without a unique key
 SAVE THE RECORD YOU ARE WRITING

   poi#=pointer(mynd)
   num#=myn:num
   clear(myn:record)

   ttelj#=0

   myn:num=num#
    set(Myn:BY_NUM,Myn:BY_NUM)
     loop
      next(mynd)
      if errorcode() then break.
      if myn:num<>num# then break.
      ttelj#+=1
     .   ! loop

    IF ttelj# > 1
     MESSAGE='YOU HAVE MORE THAN ONE TITLE FOR THIS NUMBER '&ttelj#&'

AND DECIDE WHETHER YOU WANT TO DELETE IT OR SAVE IT

   Warm regards

     Elli

CW5peB,TPS,Legacy   , win98



Tue, 11 Nov 2003 18:37:02 GMT  
 Duplicate() without a unique key
Yes, apparently, I need to debug my comments.  You would need to save the
current record.  You could do so by copying it to a string that is LIKE the
record buffer, and perhaps the record pointer to prevent complaints.

                                -Ray.


Quote:
> Thanks Ray, but its actually on a form and when I use Fetch it loses the
> record that I was on and gives "Record is not available".



Tue, 11 Nov 2003 20:20:14 GMT  
 Duplicate() without a unique key
Eric,

Quote:
> The buffer stays intact but I still get "Record is not available" when I
> click OK.  I feel as though I am missing something simple.

Buffer is intact, but you 'lost touch' with your file. Use
.SaveFile()/.RestoreFile(..)
methods to preserve file situation before test for duplicate entries.
This is the reason why .SaveBuffer()/.RestoreBuffer(..) would't work!

....
saveState  USHORT
isDup        BYTE
...

saveState = Access:MyFile.SaveFile()
GET(MyFile, 0)
isDup = DUPLICATE(MyDupKey)
Access:MyFile.SaveFile(saveState)
IF  isDup
      ! your warning message
END



Tue, 11 Nov 2003 23:00:03 GMT  
 Duplicate() without a unique key
Hello Eric,

Create an alias to your file, then you can verify against the alias. Accessing
an alias is like accessing a separate file and does not alter anything on the
file you are updating.

Quote:

> Has anyone even needed to do this ?

> I have a situation where I need to allow duplicate entries but I need to
> warn the user when one exists.
> Basically I need the Duplicate() functionality but without a unique key.  Is
> there a way to achieve this ?

> Thanks

> Eric Cossettini



Wed, 12 Nov 2003 16:05:44 GMT  
 Duplicate() without a unique key
Eric,

Look for GetState and RestoreState in the help.

loc:FileState    LONG

CODE

    loc:FileState = GetState(MyFile)
    ! Perform duplicate checking
    RestoreState(MyFile,loc:FileState)
    FreeState(MyFile,loc:FileState)

--
Pascal Gulikers
CFD 3.102 - C5.5d - CAPI 2.0 - IBM DB2 - Novell SDK
"If debugging is the process of removing bugs, then programming must be the
process of putting them in."


Quote:
> Has anyone even needed to do this ?

> I have a situation where I need to allow duplicate entries but I need to
> warn the user when one exists.
> Basically I need the Duplicate() functionality but without a unique key.
Is
> there a way to achieve this ?

> Thanks

> Eric Cossettini



Fri, 14 Nov 2003 21:03:08 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. Checking for DUPLICATES on non-unique keys

2. Not so unique Unique Keys

3. Not so unique Unique Keys - :2

4. Duplicates entries in file with unique index Why ?!?!

5. How to remove duplicate records from dbf file (uses unique index)

6. lsort -unique without sort ...?

7. Print from FORM for a file which has no unique field or key

8. Single record, non-unique key

9. Key Unique Flag - Problem

10. ODBC and not unique keys

11. Error with unique keys CW2.003

12. ODBC and not unique keys

 

 
Powered by phpBB® Forum Software