Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
Don't ask to ask, just ask
 
PerlMonks  

How can I invoke SQLPLUS within a perl script?

by Anonymous Monk
on Mar 29, 2001 at 16:22 UTC ( [id://68133]=perlquestion: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.

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

  • Comment on How can I invoke SQLPLUS within a perl script?

Replies are listed 'Best First'.
Re: How can I invoke SQLPLUS within a perl script?
by physi (Friar) on Mar 29, 2001 at 16:32 UTC
    look at CPAN Moule DBI
    and a DBD::Oracle for it.

    Then you can make a connection to your Database from in your perlscript and then use sql- for your queries.

Re: How can I invoke SQLPLUS within a perl script?
by jorg (Friar) on Mar 29, 2001 at 19:49 UTC
    If you mean sqlplus , the Oracle tool then you can invoke it through my $output = `sqlplus username/pwd @sqlfile.sql`(output of sqlplus is stored in $output) or you could do a system call as in my $rc = system('sqlplus username/pwd @sqlfile.sql')($rc contains the returncode of sqlplus)

    This is the approach you can follow to execute any system command, either backticks ``, or system().. Do a supersearch on these keywords to find more examples.

    Jorg

    "Do or do not, there is no try" -- Yoda
      Thanks. How about using "here document" ? Something like: sqlplus username/pwd <<EOF some sql code... EOF I could not make it work.
        sure you would then do:
        my $command= <<COMMAND; sqlplus / username/password @runthisfile.sql COMMAND
        then plug $command into the above described functions

        Jorg

        "Do or do not, there is no try" -- Yoda

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://68133]
Approved by root
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.