Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
List of tables in a database
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00328554
Message ID:
00328576
Views:
17
>If I have to iterate through all the tables in the database and pack them all, is there a simple command to do it? If not, what command would I use to obtain the list of tables in a database, so I could iterate them.
>
>Thanx
>Gnana

Hi Gnana,

Try this code:
LOCAL laLoop, lnLoop, lnTables
lnLoop = 0
lnTables = 0

*-- CAUTION:
*-- Substitute your database container
*-- for "MyDBC" in the next statement
OPEN DATABASE MyDBC

*-- Place the names of the tables
*-- in the container into an array
lnTables = ADBOBJECTS( laTables, "TABLE" )

*-- If tables exist in the container,
*-- loop through them
IF lnTables # 0
  FOR lnLoop = 1 TO lnTables
    USE ( laTables[ lnLoop ] ) EXCLUSIVE
    PACK
    USE

  ENDFOR && lnLoop
ENDIF && lnTables # 0
Obviously, there's no error checking with this to determine if you were successful in opening the table exclusively. Feel free to add whatever code in the FOR loop that suits your purpose(s).

HTH.
Evan Pauley, MCP
Positronic Technology Systems LLC
Knoxville, TN

If a vegetarian eats vegetables, what does a humanitarian eat?
Previous
Reply
Map
View

Click here to load this message in the networking platform