Inserting a row using shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Inserting a row using shell
# 1  
Old 05-14-2014
Inserting a row using shell

hi all,

In first run,I am inserting a row into an oracle table through shell script,
in the same shell script when I query this table the count comes as 0.

When I run the same script again then the count comes correctly,
Can anyone help how can I get the count of the row correctly in the same run when the row is inserted in table.

Thanks.
# 2  
Old 05-14-2014
use
Quote:
commit;
after inserting row..You will get correct count...
# 3  
Old 05-14-2014
Show us what you have written
# 4  
Old 05-14-2014
Code:
     entry_data_control=`sqlplus  ${sysuser}/${syspwd} << EOSQL
                      whenever sqlerror exit sql.sqlcode;
       whenever oserror exit failure;
       INSERT INTO LSHADMIN.STUDY_LEVEL_TABLE(dataload_no,SESSION_SID,SESSION_SERIAL_NO,FILE_NAME,
                                              TIMESTAMP,session_status,STUDY_NAME,BLIND_BREAK,valid_file_naming)
                select  LSHADMIN.seq.nextval,sid,$serial, '$i' ,
                        to_char(to_date($timestamp,'YYYYMMDDHH24MISS'),
                  'YYYY/MM/DD::HH24:MI:SS'),status,'$substring1','$substring3',
                  '$valid_file'
                FROM $table 
                WHERE audsid = userenv('sessionid');
       COMMIT;
       EXIT;
       EOSQL`

this is insert stmt..
 
 
Code:
update_study_tab(){
                    echo "inside update_study_tab "
     status="$1"
     name="$2"
     echo "$status"
     echo "$name"
                   update=`nohup sqlplus  ${sysuser}/${syspwd} <<UpdateTab
               whenever sqlerror exit sql.sqlcode;
      whenever oserror exit failure;
      select count(*) from lshadmin.study_level_table where study_name = '$name';
      execute LSHADMIN.update_study_tab('${name}','${status}');
       commit;
      exit;
      UpdateTab`
       echo "update $update"
                 }
I am getting count as 0 in this update stmt.

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Inserting shell script input data automatically from a text file

Dear experts, I am new to linux programming. I have a shell script which i should run it on all my samples. I only define input and out put for this script. The inputs are 3 numbers(coordination numbers) which are available in a series of text file. Since i have a lots of samples, it takes a... (5 Replies)
Discussion started by: mohamadreza
5 Replies

2. Shell Programming and Scripting

Inserting a row if patterns not followed

Hi all, I have a file of thousands of lines or rows with 2 columns. It is supposed to follow a certain pattern or blocks of 6 rows based on column 1. Below is an example: a_1 1 a_1 0.9 a_1 12 a_1 3 a_1 0 a_1 1 b_2 1 b_2 0 b_2 3 c_1 1 c_1 0 c_1 3 c_1 2 c_1 6 c_1 2 d_3 3 (1 Reply)
Discussion started by: Kanja
1 Replies

3. Shell Programming and Scripting

Problem in inserting values of variable of shell

hi all, i have one shell script like this #!/bin/bash -xv ENV_NAME=`cat $IB_HOME_DIR/cfg/ibProfile.sh | grep "RDM_CONN" | cut -f 2 -d "@"` CURRENT_DIR=`pwd`; string=$IB_HOME_DIR string1="$string/FRGFOLDER/input" #sed "s/string3/$string1" frg_event_src.sql > modifiedinsert.sql sqlplus... (2 Replies)
Discussion started by: ramsavi
2 Replies

4. Shell Programming and Scripting

Need help on inserting data from text file to excel using shell script

Hi, Please help me on this. I want to insert data from text file to excel using shell script nawk -v r=4 -v c=4 -v val=$a -F, 'BEGIN{OFS=","}; NR != r; NR == r {$c = val; print}' "file.csv" I used above one to insert $a value in 4th row, 4th column in an excel file.csv and it... (3 Replies)
Discussion started by: suman.frnz
3 Replies

5. Shell Programming and Scripting

Inserting date in unix shell with awk

Hi Friends, I have to insert date in a shell script in awk command., Shell script which i have written split on file into multiple and rename them based on some values. I want to add timestamp in the file name which is formed in after splitting the files. Dont know where am doing the mistake... (6 Replies)
Discussion started by: manish8484
6 Replies

6. UNIX for Dummies Questions & Answers

Shell Script: Traverse Database Table Row by Row

Hello Everyone, My issue is that I want to traverse a database table row by row and do some action on the value retrieved in each row. I have gone through a lot of shell script questions/posts. I could find row by row traversal of a file but not a database table. Please help. Thanks &... (5 Replies)
Discussion started by: ahsan.asghar
5 Replies

7. Shell Programming and Scripting

Script shell on line and row

Hello, I want to make a script to do this : the file is with line : TOTO TEST1 TOTO TEST2 TITI TEST1 TITI TEST2 TITI TEST3 i want he become : TOTO TEST1 TEST2 TITI TEST1 TEST2 TEST3 (3 Replies)
Discussion started by: safsound
3 Replies

8. Shell Programming and Scripting

Need shell script for inserting New line

Hi All, We have standard programming that creates large files. This file is very big. It contains header record,details records and Trailer record. Details record are of 1024 bytes(Each detail record contains summary(512 bytes) and detail(512 bytes) record). My user wants to insert new line... (16 Replies)
Discussion started by: shivakumar1231
16 Replies

9. Shell Programming and Scripting

How to do row comparison in shell script

Hi, I need help on doing the below thing in shell script. I have a file with millions of rows called "abc.txt". i have another file with millions of rows called "xyz.txt". I would like to do the below operation. Open the abc.txt, read the first line, do some operations on the column... (2 Replies)
Discussion started by: informsrini
2 Replies

10. Shell Programming and Scripting

shell script add each row value

Hi, I wrote below small script which will add up each row value from a file and print the total, but it is not.plz let me know what is wrong.script hangs and not displaying anything. ----------------- while read line ; do sum=0; sum=$sum+$line; done echo $sum; exit 0; ------------------... (8 Replies)
Discussion started by: pradeep_script
8 Replies
Login or Register to Ask a Question