![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| 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 |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
|||
|
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 |
|
|||
|
Quote:
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 |
|||
| Google UNIX.COM |