The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Getting data into and out of an OpenOffice.org Base database iBot UNIX and Linux RSS News 0 04-23-2008 11:50 AM
extracting data and store in database mam Shell Programming and Scripting 2 01-29-2008 01:08 AM
Howto capture data from rs232port andpull data into oracle database-9i automatically boss UNIX for Dummies Questions & Answers 1 09-22-2007 11:35 PM
ccall database and collect data from one table rinku Shell Programming and Scripting 0 05-27-2007 10:16 PM
Moving specific data between databases lloydnwo UNIX for Advanced & Expert Users 2 10-01-2004 05:09 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-01-2004
Registered User
 

Join Date: Sep 2004
Posts: 13
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
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 10-01-2004
google's Avatar
Moderator
 

Join Date: Jul 2002
Location: Atlanta
Posts: 740
It would be helpful to understand what database you are working with (Oracle, DB2, Access, etc) as well as which Operating System.
Reply With Quote
  #3 (permalink)  
Old 10-01-2004
zazzybob's Avatar
Registered Geek
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
Also, the OP has posted this same thread in two forums.

Read the rules, lloydnwo, and ye shall reap the benefits.
Reply With Quote
  #4 (permalink)  
Old 10-01-2004
Registered User
 

Join Date: Sep 2004
Posts: 13
Hi,

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

Regards,

lloyd
Reply With Quote
  #5 (permalink)  
Old 10-07-2004
mbb mbb is offline
Registered User
 

Join Date: Aug 2001
Location: UK
Posts: 103
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.
__________________
Senior Analyst/Programmer
Reply With Quote
  #6 (permalink)  
Old 10-07-2004
Registered User
 

Join Date: Sep 2004
Posts: 13
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
Reply With Quote
  #7 (permalink)  
Old 10-08-2004
mbb mbb is offline
Registered User
 

Join Date: Aug 2001
Location: UK
Posts: 103
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.
__________________
Senior Analyst/Programmer
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:23 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0