Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Seeking a brilliant idea to replace NextID() function
Message
De
21/01/2008 12:16:07
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
MS SQL Server
Divers
Thread ID:
01283680
Message ID:
01283715
Vues:
18
>>>I'm thinking there is no way to achieve your goal. You need to insert a record in order to get the ID. You can not get the ID without inserting.
>>
>>Why? I can do that with native tables and using a GUID as a key. There should be a way with int too, just not found yet:)
>>Cetin
>
>You can not get an ID with AutoInc fields in native either without an attempt to insert (or hacking DBF), I'm thinking this is the case here in SQL Server as well.
>
>In other words, it's an internal thing hard to get.

OK Naomi,
But I nowehere said Autoinc or Identity:) Simple updatable int field. Use mine if supplied or assign automatically if not. ie:
lnID = NextID('MyTable', 1) && allocate 1 key for me
* ...
insert into myTable (myPK) values (m.lnID)
* I may choose to not insert anything and waste the key
Or let backend do it:
insert into myTable (aFieldOtherThanPk) values ('something')
lnID = myTable.PK && it called the NextID via default, ask what has been assigned
Wish it was done with GUIDs from the start.

Cetin




Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform