Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
AutoInc data type
Message
From
16/04/2003 15:40:18
 
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00778507
Message ID:
00778554
Views:
22
>I have a field which uses the new AutoInc Integer type, and I would like to get the new ID value after I issue an INSERT INTO statement. Something like @@Identity in SQL Server. Is it possible?
>
>

If you know the name of the primary key field:
INSERT INTO table1 ....
? table1.keyID
If your program doesn't know the name of the primary key field, see KEY(), TAGCOUNT(), PRIMARY() functions...your code can figure out the name of the primary key field. Then use eval() to get the new key:

For example, assuming the primary key is the first index tag:
lcKeyField = "table1." + key(1)  && you'd have to SELECT the table, and then set the work area back
? eval(lcKeyField)
Steve Gibson
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform