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: sqlplus behaviour clarification : "could not resolve service name"

Re: sqlplus behaviour clarification : "could not resolve service name"

From: Karsten Farrell <kfarrell_at_belgariad.com>
Date: Thu, 10 Apr 2003 22:08:46 GMT
Message-ID: <MPG.18ff8b4c53bc012b98972f@news.la.sbcglobal.net>


samirks_at_operamail.com said...
> Hi,
>
> Thanks a lot for the reply. Sorry for not providing proper background of
> the problem. Here it is :
>
> Our script connecting to database has following command :
>
> sqlplus -s <username>/<passwd>@oracleDB @mysql.sql
>
> Now, sometimes the above command returns the TNS error mentioned below
> but still prompts the user for username/password. Why TNS error comes is
> a different issue which we are looking into it as the same script works
> fine most of the time (problem can be due to network issues, not sure
> though).
>
> So, just to reduce the confusion for the end user I was looking into the
> reason behind such behaviour of sqlplus and just wanted to make sure if
> we can disable this behaviour somehow. Now from your reply it is clear
> that we can't do so. In this case we have to look for other options.
>
> Please do let me know if you have any other suggestion.
>
> Thanks again for your reply.
>
> regards,
> samir
>
>
> Sybrand Bakker wrote:
> > On Thu, 10 Apr 2003 12:03:54 -0700, samir <samirks_at_operamail.com>
> > wrote:
> >
> >
> >>Hi,
> >>
> >>Even after throwing back following error :
> >>
> >>ORA-12154: TNS:could not resolve service name
> >>
> >>sqlplus prompts for username/password.
> >>
> >>Please let me know why it does so and is there a way to disable it.
> >>Basically, we don't want to prompt the user for username/password when
> >>sqlplus client fails to connect to database (we are invoking sqlplus
> >
> >>from a shell script and providing a .sql file on the command line ).
> >
> >>Thanks and regards,
> >>samir
> >
> >
> > There is no way to disable it and you'd better resolve the real
> > problem : an incorrect tnsnames.ora.
> > Information about how to resolve it is flooding in the google
> > archives, the question is asked over and over again by people who
> > don't read manuals and don't search google before posting, and in the
> > troubleshooting chapter of the net8 documentation.
> >
> >
> > Sybrand Bakker, Senior Oracle DBA
> >
> > To reply remove -verwijderdit from my e-mail address
>
>

Since you indicate that you're using a shell script, can you do something like the following?

sqlplus -s /nolog <<endsql
whenever sqlerror exit
connect x/y_at_db
@mysql
endsql

If the connect fails, you'll get an error, but won't execute mysql.sql (because of the whenever sqlerror).

-- 
/Karsten
DBA > retired > DBA
Received on Thu Apr 10 2003 - 17:08:46 CDT

Original text of this message

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