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