Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Passing integer values from shell script to a .sql file

Re: Passing integer values from shell script to a .sql file

From: Maxim Demenko <mdemenko_at_arcor.de>
Date: Tue, 06 Jun 2006 16:05:47 +0200
Message-ID: <44858d15$0$11064$9b4e6d93@newsread4.arcor-online.net>


anju schrieb:
> Hi All,
>
> i'm facing the below problem in passing integer values.
>
>
> -------------------------------------------------------
> $ ./ex5.sh
> insert into emp values ($1,'$2',$3,'$4')
> *
> ERROR at line 1:
> ORA-00911: invalid character
> -------------------------------------------------
>
> Script
>
> ==========================
> $cat ex5.sh
> #!/usr/bin/bash
>
> # this is a sample file to insert data into a table
>
> USERNAME="system"
> PASSWD="passwd"
> SID="orcl"
> declare -i val1=102
> val2="tom"
> declare -i val3=40000
> val4="boston"
>
> # database connection and updation.
>
> sqlplus -s $USERNAME/$PASSWD <<EOF
> @"/home/abc/second.sql" $val1 $val2 $val3 $val4
> EOF
> ========================================
>
> SQL file
>
> ++++++++++++++++++++++++
> insert into emp values ($1,'$2',$3,'$4')
> /
> ++++++++++++++++++++++++
>
>
>
> How can i pass integer values to the sql script.
>
>
> Thanks in advance,
> an
>

cd /home/abc
sed 's/\$/\&/g' second.sql > second_new.sql mv second_new.sql second.sql

Best regards

Maxim Received on Tue Jun 06 2006 - 09:05:47 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US