Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Increment numeric fields without Identity columns.
Message
From
12/12/2001 05:59:47
 
 
To
11/12/2001 11:02:21
Carla Silva
Http - Produtos Informaticos, Lda.
Odivelas, Portugal
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00592696
Message ID:
00593146
Views:
25
Hi!

Assuming you use SQL Server once you mentioned the identity column.

The approach is simple - use the stored procedure and a table that holds the last ID number for each table. Stored procedure gets 2 parameters - table name and output parameter - the next ID number. Call that SP using SQLEXEC() function for which you get the SQL handle from the view using CursorGetProp("ConnectHandle") function. The command for that SQLEXEC is "EXEC" for mentioned stored procedure with use of appropriate table name and "?" for returning result of SP in output paraeter. In the stored procedure just use the single UPDATE command like described in the Thread #533898 Message #534192 (id is a table, KeyName is a table name).

It is recommended also to read that thread completely for better understanding from the SQl Server point of view.

HTH.

>Hi,
>
>I have a multiuser application, and some table have a numeric field that must be incremented before the TableUpdate.
>this field can´t be an identity column, so i have to find the last number in the table to replace this field with the new number before the tableupdate. How can I do this operation and without that another user can insert a new record with the same number.
>
>I`m using Remote Views and manual transactions.
>
>Thanks,
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Previous
Reply
Map
View

Click here to load this message in the networking platform