DBAsupport.com Forums - Powered by vBulletin
Results 1 to 6 of 6

Thread: Connecting with Perl DBI as sysdba

  1. #1
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092

    Question

    Has anybody connected to oracle as sysdba through the Perl DBI? If it can be done, I can't figure out the syntax...
    Jeff Hunter

  2. #2
    Join Date
    Dec 2001
    Location
    Keene, NH
    Posts
    510
    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;
    }

  3. #3
    Join Date
    Dec 2001
    Location
    Keene, NH
    Posts
    510
    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?

  4. #4
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    Yeah, that part is no problem. The "as sysdba" is where I'm having the problem...
    Jeff Hunter

  5. #5
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    Originally posted by gopi

    Can you use a valid user with sysdba privs?
    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:
    Code:
    EXEC SQL 
        CONNECT :sys IDENTIFIED BY :SYS-PASSWD IN SYSDBA MODE 
    END-EXEC.
    but I can't figure out how to do it in Perl...
    Jeff Hunter

  6. #6
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    The fine folks at dbi-users@perl.org (Michael A Chase) pointed me to the perldoc DBD::Oracle where I need to specify DBI->connect($DSN,$USER,$PASSWD,{ora_session_mode=>2});
    Jeff Hunter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width