Moving data from one database to other


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Moving data from one database to other
# 1  
Old 10-01-2004
Moving data from one database to other

Dear All,

I have 2 databases, There is a lot of data in both the databases, i would like to move some data from one database to the other. I would like to accept 2 parameters from the user, i.e. emplyee id & dept, on entering the 2 i will unload all the data from the tables to the flat files. Now i need to load this data from the flat files in to the other database. If the data exists in the new database it should update the data. Any workarounds on it. Thanks in advance.

Regards,

lloyd
# 2  
Old 10-01-2004
It would be helpful to understand what database you are working with (Oracle, DB2, Access, etc) as well as which Operating System.
# 3  
Old 10-01-2004
Also, the OP has posted this same thread in two forums.

Read the rules, lloydnwo, and ye shall reap the benefits.
# 4  
Old 10-01-2004
Hi,

Thanks for the help, my database is informix and my os is sun solaris 8, any help is much appreciated.

Regards,

lloyd
# 5  
Old 10-07-2004
If the employee_id/department are a unique reference then, you can do something like this in a script:

EMP_ID=123
DEPT=SALES

dbaccess source_db - << !
unload to source.unl select * from source_table
where employee_id = $EMP_ID
and department = $DEPT;
!

Insert the results to a temporary table with:

dbaccess destination_db - << !
load from source.unl insert into tt_source;
!

Then:

dbaccess destination_db - << !
update dest_table set
dest_table.col1 =
(select tt_source.col1
from tt_source
where tt_source.employee_id = dest_table.employee_id
and tt_source.department = dest_table.department);
where dest_table.employee_id = $EMP_ID
and dest_table.department = $DEPT;
!

Take a backup of your databases before you try this! Use dbexport to do this.

I don't think this will be too fast if you have many updates to perform. Consider doing this with an esql/c application if you have esql/c available.
# 6  
Old 10-08-2004
Hi mbb,

Thanks for the feedback, but i need to accept the values from the user and pass it on to the other script.

Regards,

lloyd
# 7  
Old 10-08-2004
Quote:
Originally posted by lloydnwo
Hi mbb,

Thanks for the feedback, but i need to accept the values from the user and pass it on to the other script.

Regards,

lloyd
To accept user input in sh or ksh then change:

EMP_ID=123
DEPT=SALES

for:

echo "enter employee id: \c"
read EMP_ID
echo "enter department: \c"
read DEPT

The read command is basic scripting. If you code all the statements I have given you in the previous post in the same script, the values read into EMP_ID and DEPT will be substituted where they appear in the sql statement.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Help with moving list of data to 2nd column of HTML file

Hi Team, Can you help me with writing shell script to printing the list output to 2nd column in HTML file. (2 Replies)
Discussion started by: veereshshenoy
2 Replies

2. Shell Programming and Scripting

Pulling Data, Then Moving to the Next File

I'm scanning a list of emails- I need to pull 2 pieces of data, then move to the next file: Sender's Email Address Email Date I need these to be outputted into a single column- separated by a ",". Like this: Email1's Address, Email1's Date Stamp Email2's Address, Email2's Date Stamp... (4 Replies)
Discussion started by: sudo
4 Replies

3. UNIX for Dummies Questions & Answers

Data file moving

Suppose there is a file “Text1.txt” which contains 100 lines. I need to move 1st 25 line into another file “Text2.txt” How we can do it? Suppose there is a file “Text1.txt” in which city: Bangalore is repeating N times. I need to replace Bangalore with Delhi. How we can do... (1 Reply)
Discussion started by: Rajesh1412
1 Replies

4. UNIX and Linux Applications

Moving Oracle database

how does one move Oracle database to new OS? Does Oracle need to be the same version as old one? (6 Replies)
Discussion started by: orange47
6 Replies

5. Shell Programming and Scripting

Moving a column across a delimited data file

Hi, I am trying to move a column from one position to another position in a delimited file. The positions are dynamic in nature and are available by environmental variables. Also the file can have n number of columns. Example: Initial Column Position=1 Final Column Position=3 Delimiter='|' ... (2 Replies)
Discussion started by: ayan153
2 Replies

6. Shell Programming and Scripting

Moving a database from one server to another

I hope I'm posting this in the correct section. I'm trying to move a database from one server to another. This is the code I'm using... tar czf - vbdatabase.sql | ssh username@full.domain.com 'cat > /home/cpanelusername/vbdatabase.tar.gz ... but all I'm getting is a ">" and then nothing... (4 Replies)
Discussion started by: Chimpie
4 Replies

7. Infrastructure Monitoring

moving rrd data to mysql

All I currently run an application called OpenNMS. This is a free enterprise grade NMS. Its current framework uses RRDs to collect performance/node level data such as cpu load via snmp. all data is stored in these RRDs. I was wondering if anyone out there has had a chance or a need to move the... (2 Replies)
Discussion started by: pupp
2 Replies

8. UNIX for Dummies Questions & Answers

Howto capture data from rs232port andpull data into oracle database-9i automatically

Hi, i willbe very much grateful to u if u help me out.. if i simply connect pbx machine to printer by serial port RS232 then we find this view: But i want to capture this data into database automatically when the pbx is running.The table in database will contain similar to this view inthe... (1 Reply)
Discussion started by: boss
1 Replies

9. UNIX for Advanced & Expert Users

Moving specific data between databases

Dear All, I have 2 databases, There is a lot of data in both the databases, i would like to move some data from one database to the other. I would like to accept 2 parameters from the user, i.e. emplyee id & dept, on entering the 2 i will unload all the data from the tables to the flat files.... (2 Replies)
Discussion started by: lloydnwo
2 Replies
Login or Register to Ask a Question