Neethu
September 17, 2012, 10:19am
1
Hi,
I have a single value in insertval file. I want to load that value to database with the current date. I tried the below code but it is inserting <NULL> to database and echo $c is also null.
cat insertval | awk -F ' ' '{print $1}' > c
echo c=$c
data=`sqlplus -s user/pwd@hostname <<EOF
insert into Table_Name (curr_date, value) VALUES (sysdate, '$c');
commit;`
exit;
SQL
done
Regards
Neethu
You are redirecting to a FILE and reading from a VARIABLE?
Those are 2 different things.
Neethu
September 17, 2012, 10:42am
3
Hi,
I want to read the value from insertval file.
cat insertval
1.1
I want to load this 1.1 with the current date to the db.
Regards
Neethu
Replace your first line with c=$(<insertval)
and let me know.
1 Like
RudiC
September 17, 2012, 12:27pm
5
And, the HERE document is not terminated with an EOF, and, the SQL command is terminated prematurely (between commit and exit) by a backtick.
neethu:
Hi,
CODE]cat insertval | awk -F ' ' '{print $1}' > c
echo c=$c
data=`sqlplus -s user/pwd@hostname <<EOF
insert into Table_Name (curr_date, value) VALUES (sysdate, '$c');
commit;`
exit;
SQL
done[/CODE]
1 Like
Neethu
September 18, 2012, 2:24am
6
Thanks elixir and Rudic for the immediate response...
Thanks Elixir... Now the script is working fine and inserting value to DB.
Once again thanks a lot..