Wednesday, November 25, 2015

Handy howmany commandy

Here's a handy little bit of... well it isn't really SQL, is it? Shell scripting and SQL*Plus, more like.

tcsh & csh

alias howmany "echo 'select count(*) from table;' | sqlplus -s 'xxxxxx/xxxxxx@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=xxxxxx)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=xxxxxx)))'"

sh & bash

alias howmany="echo 'select count(*) from table;' | sqlplus -s 'xxxxxx/xxxxxx@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=xxxxxx)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=xxxxxx)))'"

(for ksh use either) - and then...

$ howmany


p.s. I'd love to add a pipe to

sed -e '/^$/ d; s/^\s-*//g'

but the dollar sign screws things up, at least in tcsh. Oh well!

No comments: