#!/usr/local/bin/oraperl
###!/usr/oracle/bin/oraperl
print "1..";
$OWNER='chem';
undef $ENV{'ORACLE_SID'}; # for remote client machine only
print "2..";
$ENV{'TWO_TASK'} = 'merlin8';  # for remote client machine only
#$ENV{'TWO_TASK'} = 'pacman';  # for remote client machine only

print "3..";
$ENV{'TNS_ADMIN'} = '/home/R10E/gcheng/sqlplus';
$ENV{'ORACLE_HOME'} = '/usr/npac/oracle';
  
print "4..";
#$ENV{"ORACLE_HOME"} = "/usr/oracle";

format STDOUT_TOP =
|-----------------------------------------------------------------|
|Mailbox Name        | Owner           | Logo Path                |
|====================|=================|==========================|
.
format STDOUT =
|====================|=================|==========================|
|@<<<<<<<<<<<<<<<<<<<|@<<<<<<<<<<<<<<<<|@>>>>>>>>>>>>>>>>>>>>>>>>>|
$name,$owner,$logo
|====================|=================|==========================|
.
# for remote client machine only
print 'before login ..';
$lda = &ora_login('','chem','chem') || die $ora_errstr;
print 'after login ..';
# 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 ####
