Additionally,
I have a function I call to get me a new key.
**Generates a unique number based on date and time and to use as a Primary Key
**Returns a Number: Should always be a ten digit number
FUNCTION GetKey
LOCAL cdatetime
CdateTime=str(recno())+str(seconds())+str(ROUND(RAND()*1000000000,0))
CdateTime=strtran(cdatetime,' ','')
nkey=ROUND(val(substr(CdateTime,1,10)),10)
RETURN nkey
If it's an insert I call this function and generate a key. Other wise I use the key in the where clause as Marfk stated.
It's faster than using Oracle Sequences and I use the same code for FoxPro;oracle SQL Server.
Instead of Identity columns and sequences. This gives me a new key.
Just thought I'd share that with you.
I have never ever had a duplicate key generated.
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement