Jaki1980 has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks , I have a small issue and was wondering if someone can help , I have the following code which connect to database and run an sql script:
my $sqlsource = mySql.sql open( SQLPLUS, "|sqlplus /nolog") or die "Can't rus sqlplus\n" ; print SQLPLUS <<SQL; connect USERNAME/PASS\@INST \@$sqlsource SQL
the problem is after runing the script , I am not getting back to the unix prompt , I tried to put quit or exist , however , it runs the script and stays at the sql prompt. How can I make it get back to the Unix prompt so I can call another script. thanks for any advice

Replies are listed 'Best First'.
Re: database connection
by dominix (Deacon) on Jan 16, 2004 at 21:57 UTC
    weither it's not the best (perl's)way to connect to a DataBase , you should try to
    close (SQLPLUS)

    BTW have a look at DBI. the DBI::FAQ is very instructive.
    --
    dominix
Re: database connection
by UnderMine (Friar) on Jan 16, 2004 at 22:24 UTC
    This sound more of an issue running SQL scripts in sqlplus than perl issue. So I would expect the EXIT command to be fed into SQLPLUS if it is not in the mySql.sql script.
    my $sqlsource = 'mySql.sql'; open( SQLPLUS, "|sqlplus /nolog") or die "Can't run sqlplus\n" ; print SQLPLUS <<SQL; connect USERNAME/PASS\@INST \@$sqlsource EXIT SQL close SQLPLUS;
    Hope it helps
    UnderMine
Re: database connection
by Plankton (Vicar) on Jan 16, 2004 at 22:16 UTC
    You need to add the line ...
    close SQLPLUS;
    Sorry I didn't point that out before. Just a rule of thumb if your code opens something your code should probably close it.

    Plankton: 1% Evil, 99% Hot Gas.
      thank you ;)
Re: database connection
by theguvnor (Chaplain) on Jan 16, 2004 at 22:25 UTC

    Not likely the cause of the trouble you're seeing, but you probably want to quote your SQL source:

    my $sqlsource = 'mySql.sql';

    [Jon]

      Thank you all ,, it was the close word :(