Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Invoke sqlplus

by InfiniteSilence (Curate)
on Apr 09, 2014 at 18:37 UTC ( [id://1081708]=note: print w/replies, xml ) Need Help??


in reply to Invoke sqlplus

You can write a quick SQL script that spools, execute it, and parse out its contents:
spool "foobar.dat"; select count(*) from foo_table; exit;
And then gather up the results somehow:
perl -e '`sqlplus myuser/mypassword@server @foo.sql`; my $res = `cat +foo.dat`; if($res=~m/(\d+)/){print $1}'

Celebrate Intellectual Diversity

Replies are listed 'Best First'.
Re^2: Invoke sqlplus
by chacham (Prior) on Apr 10, 2014 at 01:07 UTC

    Spool does not require a semicolon. The semicolon ends the sql buffer to be sent via the CLI to the RDBMS. spool is a sqlplus command, hence no query buffer.

    Same comment holds for exit, except, there's no reason to bother with exit anyway. Just use a document. Here's an example from asktom:

    #!/bin/csh -f sqlplus scott/tiger <<EOF exec dbms_output.put_line( 'Hello' ); EOF

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1081708]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-04-20 04:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found