The following code accumulates records from the Daily table in an archive. The Archive table is occasionally moved to tape, so the code uses the append( ) or copy( ) method, depending on whether the Archive table already exists. The Daily table is stored in a database that supports the CURRENT_DATE SQL function.

d = new Database( )

d.databaseName = "TRAFFIC"

d.loginString = "backup/murphy"

d.active = true

q = new Query( )

q.database = d

q.sql = "select * from DAILY where POSTED = CURRENT_DATE"

q.active = true

u = new UpdateSet( )

u.source = q.rowset

u.destination = "ARCHIVE.DBF"

if _app.databases[ 1 ].tableExists( "ARCHIVE.DBF" )

   u.append( ) 

else

   u.copy( ) 

endif