Copying certain data from db to db

SunDown

New Member
Hi all,

Can anybody tell me if its possible to copy certain data from one database to another database with Progress 8.3B (running on Solaris) ?
So for example, I have database A and within that there is table A1 and A2.
I also have another "empty" database B with tables B1 and B2.
I would like to do a select like command on one or more tables and transfer the output to database B.

Any help is welcome, just starting a bit with progress so.

Stefan.
 

jamesmc

Member
Hi Stefan,

Personally, I would connect to both databases (using different logical names, like a for database A and b for database B) and just do something like the following:


Code:
for each a.table1 where {whatever criteria you want} NO-LOCK:
	create b.table1. 
	buffer-copy a.table1 to b.table1.
end.

This will make an extact copy of the record from a.table1 to b.table1 and will only work if the database structures are identical.

If the tables are different then the following will work:


Code:
for each a.table1 where {whatever criteria you want} NO-LOCK:
	create b.table1. 
	assign b.table1.field1 = a.table1.field1
		b.table1.field2 = a.table1.field2
	.... and so on.
end.

HTH,

James.
 

Crittar

Member
If this is a regular job then the solution James suggested is the best one. If this is a one-off then (provided the structures are the same) dump the data from the dictionary options and import it into the second database.
 

SunDown

New Member
jamesmc said:
Hi Stefan,

Personally, I would connect to both databases (using different logical names, like a for database A and b for database B) and just do something like the following:


Code:
for each a.table1 where {whatever criteria you want} NO-LOCK:
	create b.table1. 
	buffer-copy a.table1 to b.table1.
end.

This will make an extact copy of the record from a.table1 to b.table1 and will only work if the database structures are identical.

If the tables are different then the following will work:


Code:
for each a.table1 where {whatever criteria you want} NO-LOCK:
	create b.table1. 
	assign b.table1.field1 = a.table1.field1
		b.table1.field2 = a.table1.field2
	.... and so on.
end.

HTH,

James.
Ok, looks straight forward enough, thanks for that.
But how do I connect database B ? Since I would start the progress editor on database A I would already have connection to that one.
 

Crittar

Member
Use the CONNECT statement. See the Progress language reference for syntax (it's a while since I've used it so can't recall the syntax off the top) and a possible "gotcha" - the connect to the database can't be in the same program that uses the database, so you'd have to connect using prog1.p and call prog2.p which would do the copying as detailed above.
 
Top