Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

database connection

by Jaki1980 (Novice)
on Jan 16, 2004 at 21:40 UTC ( #321922=perlquestion: print w/replies, xml ) Need Help??

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 :(

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://321922]
Approved by Plankton
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (10)
As of 2020-06-03 13:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?



    Results (23 votes). Check out past polls.

    Notices?