Path: text.usenetserver.com!atl-c01.usenetserver.com!news.usenetserver.com!atl-c05.usenetserver.com!news.usenetserver.com!postnews.google.com!i39g2000cwa.googlegroups.com!not-for-mail
From: "anju" <anjani.unix.help@gmail.com>
Newsgroups: comp.databases.oracle.misc
Subject: Re: Passing integer values from shell script to a .sql file
Date: 6 Jun 2006 07:17:59 -0700
Organization: http://groups.google.com
Lines: 74
Message-ID: <1149603479.857457.233930@i39g2000cwa.googlegroups.com>
References: <1149602011.892794.319880@h76g2000cwa.googlegroups.com>
   <44858d15$0$11064$9b4e6d93@newsread4.arcor-online.net>
NNTP-Posting-Host: 203.91.201.4
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google.com 1149603484 27199 127.0.0.1 (6 Jun 2006 14:18:04 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Tue, 6 Jun 2006 14:18:04 +0000 (UTC)
In-Reply-To: <44858d15$0$11064$9b4e6d93@newsread4.arcor-online.net>
User-Agent: G2/0.2
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727),gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: i39g2000cwa.googlegroups.com; posting-host=203.91.201.4;
   posting-account=_mlPFQ0AAACpr0DcnJousicOnIJqCh4W
Xref: usenetserver.com comp.databases.oracle.misc:240585
X-Received-Date: Tue, 06 Jun 2006 10:18:04 EDT (text.usenetserver.com)


Maxim Demenko wrote:
> 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


Thanks maxim,

actually i should use my .sql file insert stmt in the following way

insert into emp values (&1,'&2',&3,'&4')

Thanks once again,
Have a great day,
an

