Sponsored Content
Top Forums Shell Programming and Scripting Insert one table and update another with shellscript Post 302973777 by nika_mill on Saturday 21st of May 2016 10:25:26 AM
Old 05-21-2016
Wrench Insert one table and update another with shellscript

I have a problem with my shell script. I want to insert data from file to table1(empty) and then, compare table1 with table2 and update some fields.

The first part is correct, but the second part does not work. The only way it works is if after the first part I truncate table1 and run the script again.

I want to make everything in one time(insert data and update)

My shellscript:

Code:
    #!/bin/ksh    
DATE=`date +"%Y%m%d"`
PATH_LD=$HOME/myscripts/script_anuk
    PATH_BIN=$HOME/bin/myscripts/script_anuk
    PATH_LOG=$HOME/log/myscripts/script_anuk


    logfile=$PATH_LOG/script_anuk$FECHA.log
    logfileMod=$PATH_LOG/script_anuk_mod$FECHA.log

    # Insert 

    sqlldr parfile=$PATH_LD/script_anuk_param.par USERID=$CONSQLPLUS

    # Update
      sqlplus -s $CONSQLPLUS << EOF!

     SET SERVEROUTPUT ON

     SET FEEDBACK OFF
    exec declare cursor d1 is select d.book, d.phone,d.pencil from table1 d,table2 n where d.book = n.book; whow number:=0;begin for r1 in d1 loop update table2 set phone=r1.phone,pencil=r1.pencil where book = r1.book; whow := whow + 1;if mod(whow,10000) = 0 then commit; end if;end loop;end;
    exit
    EOF!

My .par

Par
Code:
USERID=/
CONTROL=$HOME/myscripts/script_anuk/script_anuk_param.ctl
DATA=$HOME/myscripts/script_anuk/data1.dat
LOG=$HOME/log/myscripts/script_anuk/script_anuk_param.log
BAD=$HOME/myscripts/script_anuk/error/script_anuk_param.bad
DISCARD=$HOME/myscripts/script_anuk/error/script_anuk_param.dsc
ERRORS=1000000
ROWS=500
DIRECT=FALSE

My .ctl
Code:
Ctl
LOAD DATA
INFILE *
INTO TABLE table1
APPEND
FIELDS TERMINATED BY ';'
(book  , 
phone         ,
pencil)
)


Can you help me please? Thank you! Smilie
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

unix script for update or insert records from a file to a oracle table

Hi, I have delimited file(|). Sample data: 1|name|50009|DS24|0|12 2|name|30009|DS24|0|13 3|name|20409|DS24|0|14 4|name|20009|DS24|0|15 5|name|10009|DS24|0|16 I want to load this data into a oracle table (update and insert) Please help me the commands and also... (1 Reply)
Discussion started by: unihp1
1 Replies

2. Shell Programming and Scripting

need to insert two columns (or two feilds) at the begining of the table

Hey guys/gals, So here is what i'm starting with...its a Solaris patch diag output. bash-3.0# pca -l Using /var/tmp/patchdiag.xref from Oct/20/08 Host: seiftsx4140 (SunOS 5.10/Generic_127128-11/i386/i86pc) List: missing Patch IR CR RSB Age Synopsis ------ -- - -- --- ---... (3 Replies)
Discussion started by: zeekblack
3 Replies

3. Shell Programming and Scripting

shellscript.query Oracle table..populate in a text file

Hi Guys, I'm new to this forum as well as to UNIX shell scripting. I'm looking for a shellscript to query an Oracle database table and populate the result set of the query in a text file. Could you someone help me out with a sample code? Thanks, Bhagat (7 Replies)
Discussion started by: bhagat.singh-j
7 Replies

4. Shell Programming and Scripting

Insert value to ORACLE table from sqlldr log

This is the sample sqlldr log: ------------------------------------------------------------------------------------------------------------ SQL*Loader: Release 9.2.0.7.0 - Production on Sun Feb 8 23:37:02 2009 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. Control... (13 Replies)
Discussion started by: aimy
13 Replies

5. Shell Programming and Scripting

select values from db1 table and insert into table of DB2

Hi I am having three oracle databases running in three different machine. their ip address is different. from one of the DB am able to access both the databases.(means am able to select values and insert values in to tables individually.) I need to fetch some data from DB1 table(say DB1 ip is... (2 Replies)
Discussion started by: aemunathan
2 Replies

6. Shell Programming and Scripting

Insert script result into Oracle Table

Hi All, I want to insert STAT and ENDTIME values for each job in joblist into TBL_DAILY_STATUS table. Eg: insert into tbl_daily_status values(STAT,ENDTIME); Please help me on this. #!/bin/ksh joblist="com_abc_job com_abc_dot_job com_abc_seq com_abc_det" for i in $joblist do... (8 Replies)
Discussion started by: vichuelaa
8 Replies

7. Programming

Table Locking in Insert Command.

Hi, i have a java based tool which does insert operation in a TABLE, and in parallel the same table is used by my C++ code which does select Query. the Table will be always busy, but sometimes the table is getting locked when i try to make an insert, am bit confused whether the lock is... (0 Replies)
Discussion started by: senkerth
0 Replies

8. Shell Programming and Scripting

Insert bulk values in DB table using isql

Hello, Objective is to insert bulk values in DB table using isql. Following code tried: isql -SServer_name -Ddb_name -Uuser_name -Ppassword < file.txt cat file.txt for i in `cat data_value_file.txt` do insert into tempdb..temp_table11 values ('$i') go done cat... (3 Replies)
Discussion started by: manishdivs
3 Replies

9. Programming

MYSQL - trigger update on record insert or update

Right I have a MYSQL database with table1 with 3 columns, colA, colB and colC. I want to combine the data in the 3 columns into a 4th column names col_comb. Here's the SQL command that works: UPDATE table1 SET `col_comb` = CONCAT( `colA` , ' - ', `colB` , ', ', `colC` ); So now I want this... (5 Replies)
Discussion started by: barrydocks
5 Replies

10. Programming

How to track table status delete/update/insert status in DB2 V10 z/os?

Dear Team I am using DB2 v10 z/os database . Need expert guidance to figure out best way to track table activities ( Ex Delete, Insert,Update ) Scenario We have a table which is critical and many developer/testing team access on daily basis . We had instance where some deleted... (1 Reply)
Discussion started by: Perlbaby
1 Replies
KPROPLOG(8)						      System Manager's Manual						       KPROPLOG(8)

NAME
kproplog - display the contents of the Kerberos principal update log SYNOPSIS
kproplog [-h] [-e num] DESCRIPTION
The kproplog command displays the contents of the Kerberos principal update log to standard output. It can be used to keep track of the incremental updates to the principal database, when enabled. The update log file contains the update log maintained by the kadmind process on the master KDC server and the kpropd process on the slave KDC servers. When updates occur, they are logged to this file. Subsequently any KDC slave configured for incremental updates will request the current data from the master KDC and update their principal.ulog file with any updates returned. The kproplog command can only be run on a KDC server by someone with privileges comparable to the superuser. It will display update entries for that server only. If no options are specified, the summary of the update log is displayed. If invoked on the master, all of the update entries are also dis- played. When invoked on a slave KDC server, only a summary of the updates are displayed, which includes the serial number of the last update received and the associated time stamp of the last update. OPTIONS
-h Display a summary of the update log. This information includes the database version number, state of the database, the number of updates in the log, the time stamp of the first and last update, and the version number of the first and last update entry. -e num Display the last num update entries in the log. This is useful when debugging synchronization between KDC servers. -v Display individual attributes per update. An example of the output generated for one entry: Update Entry Update serial # : 4 Update operation : Add Update principal : test@EXAMPLE.COM Update size : 424 Update committed : True Update time stamp : Fri Feb 20 23:37:42 2004 Attributes changed : 6 Principal Key data Password last changed Modifying principal Modification time TL data SEE ALSO
kpropd(8) KPROPLOG(8)
All times are GMT -4. The time now is 01:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy