Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Seeking a brilliant idea to replace NextID() function
Message
From
21/01/2008 11:51:16
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
MS SQL Server
Miscellaneous
Thread ID:
01283680
Message ID:
01283698
Views:
14
>>I have a project that's working against native VFP tables. Now I'm in the process of making this SQL+Native switchable.
>>
>>Project unfortunately use int keys as primary keys and worse implemented the NextID() similar to the one in solution samples (well may it looked good in those days where it was first build). There are places where you need to know the key before inserting and places where it's simply not specified in insert and gets its default value from NextID().
>>
>>In SQL server though, you cannot specify a function that inserts/updates data (namely it should isert/update IDS table). IDENTITY wouldn't work either (remember sometimes it needs to get the key before insertion). Replacing PKs with GUIDs would be an easy solution but unfortunately in code there are many places the value is checked as being 0 or not.
>>
>>The question is how would you implement this? I tried INSTEAD OF trigger, but failed (really might work, just couldn't write the code that would work for multiple inserts yet). My idea so far:
>>Use CA and in beforeinsert call NextID SP, update the command sent. However it wouldn't work with batch updates. BeforeCursorUpdate is what I think the place to do this. Not having used CA much I don't have a clear idea if that would work. Has anyone tried or have a better idea?
>>TIA
>>Cetin
>
>Check Message #1111814

I checked, probably brain dead now, can't see how it helps to know the key before inserting a new record.
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform