Generally I have used the AttachDatabase function to perform cross database
queries. The attachdatbase commands attachs another database file to the
currently connected database. Once attached you can perform cross-database
queries. In order to attach an encrypted database, you must pass the correct
password/encryptionkey for the database to be attached. You can also attach
more than one datbases to a connected database. To detach a database you use
the DetachDatabase command. Closing the connection to the original connected
database automatically detachs the attached databases.
To attach to a connected db, you can attach using something like this:
if db.AttachDatabase(File, DatabaseName, EncryptionKey) = true then
return true
else
return False
end if
You can then use the db.SQLExecute to perform a cross database query.
For example if you are connected to "database1" and you attach "database2"
using the AttachDatabase and both databases contain a table called "table1"
with 3 columns "column1","column2" and "column3" you could then
perform the following query.
db.SQLExecute("INSERT INTO database2.table1 (column1,column2,column3)
SELECT column1, column2, column3 FROM table1 database1 WHERE rowid between
'1' and '10';")
This sql statement should copy the records from table1 in database1 for
column1, column2, column3 and insert the records in the columns for
database2 (the attached database) if they meet the WHERE criteria. The WHERE
statement is optional but it illustrates how you could get the records from
one REALSQLdatabase from one file to another in particular cases.
You can also mix and match the columns but be aware that when you copy from
one column to another with different datatypes say a varchar to a integer
column the varchar text may be turned into zeros by REALbasic.
Hope this helps,
Paul Hosking
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Dennis
Birch
Sent: miercoles, 09 de mayo de 2007 14:19
To: RBNUG
Subject: Copying REALSQLdatabase data from one file to another
I'm trying to figure out how to do a partial backup of data stored in
REALSQLdatabase files, and I'm feeling very stuck right now.
Is there a way of copying the data from one REALSQLdatabase file to a
clone of the same file other than looping over every record that I
want to copy from every table that I want to copy? In other words, is
there some way of doing a SELECT on one the data in one file and
inserting the results of that SELECT into a table in another file with
the same name and columns?
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>