Has anybody connected to oracle as sysdba through the Perl DBI? If it can be done, I can't figure out the syntax...
Printable View
Has anybody connected to oracle as sysdba through the Perl DBI? If it can be done, I can't figure out the syntax...
I guess you have connecting to Oracle with a valid user working.
#################################################
# Connect to Oracle as username/oldpassword ##
#################################################
use DBI;
print "connect string: $username/\"$oldpassword\"\@$database \n";
$dbh = DBI->connect("dbi:Oracle:$database","$username",$oldpassword, {PrintError => 1} );
if ($DBI::errstr =~ /ORA-28002/) {
# this is the 'expire in 3 days' message
print "***User/oldpassword/database valid: connection okay ***\n";
} elsif ($DBI::errstr =~ /ORA-/) {
print "***User/oldpassword/database invalid: connecting failed - check authentication and db name (tns) \n $DBI::errstr \n";
exit 1;
} else {
print "*** connecting as user with old password: connection okay ***\n";
$dummy = 1;
}
I hit the submit button when I meant to hit the preview button (more code than you asked for).
Can you use a valid user with sysdba privs?
Yeah, that part is no problem. The "as sysdba" is where I'm having the problem...
Unfortunately, you can connect with a userid/password of a sysdba user, but still not able to perform sysdba functions unless you specify "as sysdba". In PRO*C, you would have to:Quote:
Originally posted by gopi
Can you use a valid user with sysdba privs?
but I can't figure out how to do it in Perl...Code:EXEC SQL
CONNECT :sys IDENTIFIED BY :SYS-PASSWD IN SYSDBA MODE
END-EXEC.
The fine folks at [email protected] (Michael A Chase) pointed me to the perldoc DBD::Oracle where I need to specify DBI->connect($DSN,$USER,$PASSWD,{ora_session_mode=>2});