Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can someone give me an example of a system Id 1

Status
Not open for further replies.

tripp2222

Technical User
Nov 30, 2004
32
US
What is a system Id?
 
This is how it is being used.

lnSelect = SELECT() && Store alias number to variable
SELECT Systemids
SET EXACT ON

LOCATE FOR UPPER (ALLTRIM (tTablename))=UPPER (ALLTRIM (Systemids.tablename))
IF NOT FOUND ()
APPEND BLANK
LOCK()
REPLACE Systemids.tablename WITH tTablename
lIDValue=Systemids.idvalue
lIDValue=lIDValue+1
REPLACE Systemids.idvalue WITH lIDValue IN Systemids
UNLOCK IN Systemids
 
Trip,

In this case, Systemids is the name of a table (to be more precise, it's the alias of the name of the table, but the distinction isn't important in this context).

When you say SELECT Systemids, you are telling Foxpro that the Systemids table will be the current or active table. Subsequent commands and functions will operate on that table, until you tell it otherwise.

So, for example, your LOCATE command, which searches a table for a given record, will now search the Systemids table.

What this code appears to be doing is to generate a primary key. The systemids table seems to contain values to be used as keys. When you want a new key, you search the table for the current key, add one to it, and write it back to the table. Rick has given you a fuller explanation of this in Thread1252-984297.

I hope this helps. I know VFP can be a bit confusing to start with, but persevere and it will eventually become clear.

Mike




__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Hi tripp2222,

From the code you posted, it seems the SystemIDs Table is a table storing the last ID of each other table of the database and is used for generating primary key values. I bet somewhere later the function returns lIDValue and a call to this code is made as a default value of the primary key fields of tables in this database.

It's not specific to windows, foxpro or databases in general to call this SystemIDs, but it seems okay so far.

Having problems with it? Duplicate IDs, Error 1884: "Uniqueness of index <name> is violated." ?

I'd recommend using FLOCK() on a seperate ID-table for each table of the database. eg. "sysID_tabCustomers" as ID-Table for Table "tabCustomers". That's more reliant than LOCK on a record.

Bye, Olaf.
 
Thanks Craig,

I understand sysId a little better now that I can see it in another language. VFP is really different from what I learned in school

Kristian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top