• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 224
  • Last Modified:

combining two databases

I've got two dBase IV databases (or actually user chooses them) and
1. I wanna chech that databases structures are same kind of that bases can be compined.
2. Then I wanna add one database to another so that there isn't any dublicates (or make a new one).

Example:
I've got one database where is datas from 1/1/1998 30/6/1998 and another where is data from 1/5/1998 to 31/7/1998. Then user can choose if he wanna update first database or update second database or make a new database where is datas from 1/1/1998 to 31/7/1998.

I guess I can some way open Recordset so that it chooses datas from both databases so that there isn't dublicates and then I have to make a new database where I copy those Recordsets datas? Or can I open recordset which chooses only datas from DB1 which aren't in DB2 and copy datas in the DB2 or vice versa?

Could give an example how to do this.

Thanks in advance!
0
majala
Asked:
majala
  • 4
  • 3
1 Solution
 
watyCommented:
One good solution is creating Insert SQL statment and execute them. If the insert has inserted, all is allright for you. If the insert fails, the rows was previously in the DB.

This is the fastest way to do.

on error resume next
DB.Execute "Insert into..."


0
 
majalaAuthor Commented:
What kind of is that insert SQL statement?

Isn't that a little bit slow way? If there is 20 000 lines in a DB1 and I wanna add only last 50 from those lines to DB2, I have to still check all those 20 000 lines!
0
 
majalaAuthor Commented:
What kind of is that insert SQL statement?

Isn't that a little bit slow way? If there is 20 000 lines in a DB1 and I wanna add only last 50 from those lines to DB2, I have to still check all those 20 000 lines!
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
watyCommented:
If you know wich records to add, you can add them directly. If you don't know wich are the records to add, this is the fastest way.

The SQL looks like
   sSQL = "Insert Into Spool (userid, print_group, ps_job, nomd, prenomd, "
   sSQL = sSQL & "batiment, etage, bureau, execution_time)"
   sSQL = sSQL & "VALUES (LPAD (to_char (" & Format(gnSequence, "0000") & "), 4, '0'), "
   sSQL = sSQL & "'" & clsDestinataire.sPrintGroup & "', '" & sJob & "', "
   sSQL = sSQL & "'" & clsDestinataire.sNomd & "', '" & clsDestinataire.sPrenomd & "', "
   sSQL = sSQL & "'" & clsDestinataire.sBatiment & "', '" & clsDestinataire.sEtage & "', "
   sSQL = sSQL & "'" & clsDestinataire.sBureau & "', sysdate) "

   DB.Execute sSQL

But before, you have to read the record to add.

NB : This is the fastest way to do with access, SQL Server, Oracle, but I have never tested it with DBase
0
 
majalaAuthor Commented:
Looks kind of weird. Could give some explanations what those lines do (mean).
What are these: userid, print_group, ps_job, nomd, prenomd.

DB.Execute sSQL (is this DB my destination or target DB?)

Could this do any good?

Dim srcRS as Recordset
Dim destRS as Recordset
Dim SQL as string

SQL ="SELECT * FROM MyTable WHERE MyField = '"& srcRS("MyField) & "'"
set destRS = db.OpenRecordset(SQL)
0
 
watyCommented:
Oops, I have taken this query from the current application I am working on. You don't have to care.

Give me the description of your table, and I will post the query you need to execute.

DB.Execute sSQL => DB is the destination DB

Give me also the complete SQL you use to retrieve the data.
SQL ="SELECT Field1, .... FROM MyTable WHERE MyField = '"& srcRS("MyField) & "'"
set destRS = db.OpenRecordset(SQL)

0
 
majalaAuthor Commented:
Those table structures can chance, so I hope to get this work any kind of two dBase databases (of cource those two tables have to be similar).

Actually I don't have any complete SQL what I use to retrieve my data. There is also one thing, there is separated Date and Time fields in my database. So I guess one have to compare both fields before can be sure that those fields are different or similar.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now