>>lSuccess = .f.
>>Do While Not lSuccess
>> cSQL = "SELECT LastNumber FROM NumberTable WHERE cKey = 'TABLENAME'"
>>
>> SQLExec(nConn, cSQL)
>>
>> nLastNumber = SQLResult.LastNumber
>> nNewId = nLastNumber + 1
>>
>> cSQL = "UPDATE NumberTable SET LastNumber = nNewID WHERE "+ ;
>> "cKey='TABLENAME' and LastNumber = nLastNumber"
>>
>> lSuccess = ( SQLExec(nConn, cSQL) = 1 )
>>EndDo
>
>
>Thanks Bob, this seems to be a good solution. Not the most elegant way to obtain the goal, but I suppose there is no better way. Wouldn't have found it myself ....
Of course, if you are using the value for a primary key, you may want to consider using the UniqueIdentifier data type and GUID values... this eliminates the need to go to the back end for every id.
BOb
Précédent
Suivant
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