Total Pageviews

Monday 11 March 2013

DBI connect ORA-28009:(DBD ERROR: OCISessionBegin)

When trying to connect remote oracle database using Perl as SYSDBA got the below error :

my $dbh = DBI->connect( "dbi:Oracle:orcl", "SYS", "sys", {ora_session_mode =>ORA_SYSDBA,RaiseError => 1,AutoCommit => 0 })
 or die "Can't open orcl database: $DBI::errstr";


my $dbh = DBI->connect( "dbi:Oracle:orcl", "SYS", "sys", {RaiseError => 1,AutoCommit => 0 })
 or die "Can't open $db_name database: $DBI::errstr";
 


 Error Msg:

DBI connect('orcl','sys',...) failed: ORA-28009: connection as SYS should be as SYSDBA or SYSOPER (DBD ERROR: OCISessionBegin) 

Solution:

Use the below updated script to connect oracle DB using Perl (SYSDBA role):
  
#!/usr/bin/perl

use strict ;

use DBI;
use Getopt::Long qw(:config no_ignore_case);

#use DBD::Oracle qw(ora_session_modes);

my $dbh = DBI->connect( "dbi:Oracle:orcl", "SYS", "sys", {ora_session_mode =>2,RaiseError => 1,AutoCommit => 0 })
 or die "Can't open $db_name database: $DBI::errstr";

my $sth = $dbh->prepare( "SELECT * FROM dba_tables" )
      or die "Can't prepare SQL statement: $DBI::errstr\n";

  ### Execute the statement in the database
  $sth->execute
      or die "Can't execute SQL statement: $DBI::errstr\n";

  ### Retrieve the returned rows of data
  my @row;
  while ( @row = $sth->fetchrow_array(  ) ) {
      print "Row: @row\n";
  }
  warn "Data fetching terminated early by error: $DBI::errstr\n"
      if $DBI::err;

$dbh->disconnect
      or warn "Error disconnecting: $DBI::errstr\n";

  exit;

2 comments:

  1. Jadwal Arena Sabung Ayam SV388 28 Februari 2019 - Kamis, Maluku 28 Februari 2019 – Pada Hari Tersebut Akan Di Laksanakan Berbagai Pertandingan Sabung Ayam Secara Live di Arena Sabung Ayam Thailand.

    Situs Judi Sabung Ayam Online SV388 Merupakan Situs Judi Asal Thailand Yang Sangat Terkenal Dengan Permainan Sabung Ayam Yang Fair dan Menghibur Para Penonton Judi Sabung Ayam.

    Untuk Info Lebih Lanjut Bisa Hub kami Di :
    wechat : bolavita
    line : cs_bolavita
    whatsapp : +628122222995
    BBM: BOLAVITA

    ReplyDelete
  2. Hello Everybody,
    My name is Mrs Sharon Sim. I live in Singapore and i am a happy woman today? and i told my self that any lender that rescue my family from our poor situation, i will refer any person that is looking for loan to him, he gave me happiness to me and my family, i was in need of a loan of $250,000.00 to start my life all over as i am a single mother with 3 kids I met this honest and GOD fearing man loan lender that help me with a loan of $250,000.00 SG. Dollar, he is a GOD fearing man, if you are in need of loan and you will pay back the loan please contact him tell him that is Mrs Sharon, that refer you to him. contact Dr Purva Pius, call/whats-App Contact Number +918929509036 via email:(urgentloan22@gmail.com) Thank you.

    ReplyDelete