SQL::TableSnapshot Example: A Single Table

Description

Create and manage a snapshot of a single table using the same object (SQL::TableSnapshot) that SQL::DatabaseSnapshot uses to manage its collection of tables.

Although we have focused on snapshots of collections of tables, you can also create and manage a snapshot of a single table using the same object (SQL::TableSnapshot) that SQL::DatabaseSnapshot uses to manage its collection of tables. In this example, we snapshot the Contacts table. Note that we must first get the table definition from the database and then pass it to the load function of SQL::TableSnapshot.

dim cn as SQL::Connection 
dim ts as SQL::TableSnapshot 
dim ti as SQL::TableInfo 

' Open the source database 
cn.open("::Name::MyDatabase")

' Load the schema from the source database
cn.GetTableInfo(ti, "Contact") 

' Take a snapshot of table
 ts.load(cn, ti)

' Save the snapshot as XML
file.from_string("<MyFile>", ts.XML)