#!/home/R10E/gcheng/sqlplus/bin/oraperl
###!/usr/oracle/bin/oraperl
$OWNER='Gang Cheng';
undef $ENV{'ORACLE_SID'}; # for remote client machine only
$ENV{'TWO_TASK'} = 'kayak';  # for remote client machine only
format STDOUT_TOP =
|-----------------------------------------------------------------|
|Mailbox Name        | Owner           | Logo Path                |
|====================|=================|==========================|
.
format STDOUT =
|====================|=================|==========================|
|@<<<<<<<<<<<<<<<<<<<|@<<<<<<<<<<<<<<<<|@>>>>>>>>>>>>>>>>>>>>>>>>>|
$name,$owner,$logo
|====================|=================|==========================|
.
# for remote client machine only
$lda = &ora_login('','gcheng','gcheng') || die $ora_errstr;
# for local machine
#$lda = &ora_login('nodb','gcheng','gcheng') || die $ora_errstr;

$csr = &ora_open($lda,'select name,owner,logo from mailbox where owner!=\'$OWNER\'')|| die $ora_errstr;

$nfields = &ora_fetch($csr);
print "Query will return $nfields fields \n\n";

while (($name,$owner,$logo) = &ora_fetch($csr)) { write;}
warn $ora_errstr if $ora_errno;

die "fetch error: $ora_errstr" if $ora_errno;
do ora_close($csr) || die "can't close cursor";
do ora_logoff($lda) || die "can't log off Oracle";

############## END ####
