Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can a Table Reference in a Database be Checked?
Message
From
05/04/2000 00:07:21
George Simon
GS Data Technologies, LLC
Cincinnati, Ohio, United States
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00355475
Message ID:
00355498
Views:
24
Michael

>Therefore, is it possible to check whether a table is already referenced in a database, so that it can be removed if the table is missing?

To find orphan table references in the DBC you could do something like this:

OPEN DATABASE YourDBC
lnTableCount = ADBOBJECTS(laTableList,'TABLE')
FOR lnRow = 1 TO ALEN(laTableList)
IF NOT FILE( ALLTRIM(laTableList[lnRow]) + '.dbf' )
? '"' + ALLTRIM(laTableList[lnRow]) + '.dbf" does not exist.'
ENDIF
ENDFOR
CLOSE DATABASE

You would actually store the missing file names into another array or cursor. Once you have a list of orphan table references, you can then open the DBC as a dbf. In other words:

USE YourDBC.dbc

Now you can SCAN the dbc for orphan table references and DELETE them.

I suggest you have your utility make a backup copy of your dbc, dct, and dcx files before it actually starts modifying the data!

HTH

PS
If you are in the process of developing a set of database utilities, you might consider looking at Stonefield Database Toolkit. It could save you months of effort!
George Simon, MCP
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform