Sorry, but there is no way. / as sysdba is a SQL*Plus specific command. I opened a tar with oracle on the issue of being able to connect / as sysdba and using OCI to shutdown the database like the shutdown command in SQL*Plus. They told me that neither could be done. I created a user with very specific privileges and set very restrictive permissions on my script that contains that information. I also created packages to do specific things and granted execute on those packages to that user. That is the best solution that I have been able to come up with. I hope that helps.
use DBD::Oracle qw(:ora_session_modes);
# Connect and initialise.
my %attr = ( AutoCommit => 0, PrintError => 0 };
if ($username =~ /^SYS\s+AS\s+(SYS(?:DBA|OPER))$/i) {
$username = 'SYS';
if ($1 =~ /^SYSDBA$/i) {
$attr{ora_session_mode} = ORA_SYSDBA;
} else {
$attr{ora_session_mode} = ORA_SYSOPER;
}
}
if (! ($Db = DBI->connect("dbi:Oracle:$database",
$username, $password, \%attr))) {
error("Can't login to Oracle:", $DBI::errstr);
return(0);-- Alan Burlison --
