Insert script result into Oracle Table


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Insert script result into Oracle Table
# 1  
Old 12-24-2012
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.

Code:
#!/bin/ksh
joblist="com_abc_job com_abc_dot_job com_abc_seq com_abc_det"
for i in $joblist
do
STAT=`./JobStatus.pl  -i NP1 -z Z8PIMBN -p $i|awk '{print $6}'`
ENDTIME=`./JobStatus.pl  -i NP1 -z Z8PIMBN -p $i|awk '{print $4" " $5}'`
echo "$STAT"
echo "$ENDTIME"
done


Last edited by Scott; 12-24-2012 at 07:51 AM.. Reason: Please use code tags
# 2  
Old 12-24-2012
Code:
ORACLE_SID=<db name>
ORAENV_ASK=NO
. /usr/local/bin/oraenv

for i in ....
...
sqlplus /nolog << !
  connect user/pass
  insert into tbl_daily_status values('$STAT','$ENDTIME');
!
...
done

# 3  
Old 12-24-2012
Code:
sqlplus -s user/pwd@DB << EOF
insert into tbl_daily_status values(${STAT},${ENDTIME});
EOF

# 4  
Old 12-24-2012
Insert into oracle table

Hi Scott,

I am getting below error.

Quote:
Originally Posted by Scott
Code:
ORACLE_SID=<db name>
ORAENV_ASK=NO
. /usr/local/bin/oraenv
 
for i in ....
...
sqlplus /nolog << !
  connect user/pass
  insert into tbl_daily_status values('$STAT','$ENDTIME');
!
...
done



Code:
"batch.sh" 42 lines, 497 characters 
PaBatchd_234>>batch.sh
FA
09/28/2012 03:05:22
SU
09/07/2012 05:56:51
RU
----- -----
RU
----- -----

batch.sh[13]: syntax error at line 14 : `newline or ;' unexpected
PaBatchd_234>>

Last edited by Scott; 12-24-2012 at 09:28 AM.. Reason: Code tags
# 5  
Old 12-24-2012
If ENDTIME is a DATE type, try:
Code:
insert into tbl_daily_status values('$STAT', to_date( '$ENDTIME', 'MM/DD/YYYY HH24:MI:SS' ));

In future, please describe the table(s) in question, and show some example data / output. Thanks.
# 6  
Old 12-24-2012
Will tbl_daily_status reflect WHICH job had that stat and endtime?
# 7  
Old 12-26-2012
Hi Scott,

I am getting below error.

Code:
PaBatchd_234>>batch.sh
FA
09/28/2012 03:05:22
SU
09/07/2012 05:56:51
RU
----- -----
RU
----- -----

batch.sh[14]: /usr/local/bin/oraenv: not found

Last edited by Scott; 12-26-2012 at 05:25 AM.. Reason: Code tags, please...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Help on Oracle insert from shell script

Hi All I am trying to create a shell script to insert in to oracle table so far insert happens with out an issue, but i cant pass message variable to sqlplus script insert. i have highlighted the variable in red. Please help. thanks in advance. #!/bin/sh df -H | grep -vE... (3 Replies)
Discussion started by: LPK
3 Replies

2. Shell Programming and Scripting

Python Script to take file count and insert into DB2 table

Team I have files in different directories . How can i take the count of latest file and insert into Db2 table . I am using awk 'END{print NR+1-ARGC}' (File name) to get the counts. How can i take 1.The count of latest file 2.Insert into Db2 table( File Name and Counts) . cd... (4 Replies)
Discussion started by: Perlbaby
4 Replies

3. Shell Programming and Scripting

Intelligent Script to Insert Records in Database Table

Hello All Members, I am new to this forum and to the shell scripting. I want to write a shell script to do the following: Scenario: I have a pipe delimited .txt file with multiple fields in it. The very first row of the file contains the name of the column which resembles the name of the... (18 Replies)
Discussion started by: chetanojha
18 Replies

4. Shell Programming and Scripting

Bash script to display result in table

My script gives the following result. Is it possible to display the same in table format ? 1. rex_best Latest feeds are not avaialable. The last feed was generated on 2012-05-17 File Name = ekb_best_20120517_010949_665.tar.gz The Number of entry elements = 4209539 2. rex_genre Latest... (2 Replies)
Discussion started by: kishorekumar87
2 Replies

5. UNIX for Dummies Questions & Answers

Bash script to insert data into an html table

hi, I need to create a bash shell script which picks up data from a text file and in the output file puts it into an html made table. I have to use sed and awk utilties to do this the input text file will contain data in the format: job name para1 para2 para3 para4 para4 1 ... (1 Reply)
Discussion started by: intern123
1 Replies

6. Shell Programming and Scripting

Insert into Oracle table thru UNIX - linux 2.6.9-89

Hi, I am trying to insert a record into a table (say dips_tbl) which resides in Oracle DB through a ksh script. I want to insert records into few of the table columns-not all. I'll give an e.g. for the date column "CREATE_DATE". For that I first execute SQL1="SELECT SYSDATE FROM DUAL" ... (1 Reply)
Discussion started by: dips_ag
1 Replies

7. 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

8. 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

9. 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

10. Programming

How can i load or insert a table in oracle from c language thru unix environment

I'm having a oracle server and i'm having a table in that. I'm having a linux server which is in network with the oracle server. I need to write a c program in linux env when on execution loads the table with the text file given as input. Please explain me the flow of process in that and also... (6 Replies)
Discussion started by: rramprasad
6 Replies
Login or Register to Ask a Question