Réf. : RE: connect to oracle database as sysdba form windows

From: Pierre Henon (pierre.henon_at_ccf.com)
Date: 09/27/04


To: "Reidy, Ron" <Ron.Reidy@arraybiopharma.com>
Date: Mon, 27 Sep 2004 09:06:24 +0200


Hi Ron

I already tried that and It works. The problem is that the "sysdba" connection is completely ignored

Pierre HENON
HSBC-CCF
Banque de Grande Clientèle
103, Avenue des Champs-Elysées
75008 PARIS
FRANCE
Tel : + 33 (0) 1 40 70 73 16
Fax : + 33 (0) 1 40 70 70 65

                                                                                                                                                                     
                                                                                                                                                                     
                                                Pour : "Reidy, Ron" <Ron.Reidy@arraybiopharma.com>, Pierre HENON/HDQ/HBFR/HSBC@HSBC, <dbi-users@perl.org>
                                                cc :
                                                Objet : RE: connect to oracle database as sysdba form windows
             "Reidy, Ron"
             <Ron.Reidy@arraybiopharma.com
>
                                                                                                                                                                     
             24/09/2004 19:10
                                                                                                                                                                     
                                                                                                                                                                     
                                                                                                                                                                     

Sorry - I didn't see the code (sick with a really bad cold).

Anyway, does "t" have SYSDBA privs? What happens if you run "sqlplus "t/t@db as sysdba" from a cmd.exe prompt?

-----------------
Ron Reidy
Lead DBA
Array BioPharma, Inc.
303.386.1480

-----Original Message-----
From: Reidy, Ron
Sent: Friday, September 24, 2004 11:04 AM
To: pierre.henon@ccf.com; dbi-users@perl.org
Subject: RE: connect to oracle database as sysdba form windows

read the DBD::Oracle docs.

-----------------
Ron Reidy
Lead DBA
Array BioPharma, Inc.

-----Original Message-----
From: pierre.henon@ccf.com [mailto:pierre.henon@ccf.com]
Sent: Friday, September 24, 2004 7:18 AM
To: dbi-users@perl.org
Subject: connect to oracle database as sysdba form windows

Hi,

I would like to connect to an Oracle database as sysdba from perl, so I use the script joined below.
I use, for example :

perl test.pl -database prebcc -username "t" -password "t" -sysdba

But the sysdba parameter is not taken into account. If user t exists with password t the connection is made as t (should be as sysdba) if it doens not exists I have the "invalid username/password; logon denied" error.

Yet this program is working on Unix. So can anybody help me?

#!/usr/local/bin/perl

# template for DBI programs

# use warnings;
use DBI;
use strict;

use Getopt::Long;

my %optctl = ();

Getopt::Long::GetOptions(
   \%optctl,
   "database=s",
   "username=s",
   "password=s",
   "sysdba!",
   "sysoper!",
   "z","h","help");

my($db, $username, $password, $connectionMode);

$connectionMode = 0;
if ( $optctl{sysoper} ) { $connectionMode = 4 }
if ( $optctl{sysdba} ) { $connectionMode = 2 }

if ( ! defined($optctl{database}) ) {
   Usage();
   die "database required\n";
}
$db=$optctl{database};

if ( ! defined($optctl{username}) ) {
   Usage();
   die "username required\n";
}

$username=$optctl{username};
$password = $optctl{password};

print "USERNAME: $username\n";
print "DATABASE: $db\n";
print "PASSWORD: $password\n";
print "connect: $connectionMode\n";
#exit;

my $dbh = DBI->connect(
   'dbi:Oracle:' . $db,
   $username, $password,
   {
      ora_session_mode => $connectionMode
   }
   );

die "Connect to $db failed \n" unless $dbh;

$dbh->{RowCacheSize} = 100;

my $sql=q{select USER from dual};

my $sth = $dbh->prepare($sql,{ora_check_sql => 0 });

$sth->execute;

while( my $ary = $sth->fetchrow_arrayref ) {
   print "\t\t$${ary[0]}\n";
}

$sth->finish;
$dbh->disconnect;

sub Usage {
   print "\n";
   print "usage: DBI_template.pl\n";
   print " DBI_template.pl -database dv07 -username scott -password tiger [-sysdba || -sysoper]\n";
   print "\n";
}

Pierre HENON
HSBC-CCF
Banque de Grande Clientèle
103, Avenue des Champs-Elysées
75008 PARIS
FRANCE
Tel : + 33 (0) 1 40 70 73 16
Fax : + 33 (0) 1 40 70 70 65

Les informations contenues dans ce message sont confidentielles et peuvent constituer des informations privilegiees. Si vous n etes pas le destinataire de ce message, il vous est interdit de le copier, de le faire suivre, de le divulguer ou
d en utiliser tout ou partie. Si vous avez recu ce message par erreur, merci de le supprimer de votre systeme, ainsi que toutes ses copies, et d en avertir immediatement l expediteur par message de retour.
Il est impossible de garantir que les communications par messagerie electronique arrivent en temps utile, sont securisees ou denuees de toute erreur ou virus. En consequence, l expediteur n accepte aucune responsabilite du fait des erreurs
ou omissions qui pourraient en resulter.
--- ----------------------------------------------------- ---
The information contained in this e-mail is confidential. It may also be legally privileged. If you are not the addressee you may not copy, forward, disclose or use any part of it. If you have received this message in error, please delete
it and all copies from your system and notify the sender immediately by return e-mail.
E-mail communications cannot be guaranteed to be timely secure, error or virus-free. The sender does not accept liability for any errors or omissions which arise as a result.
$!2$!

This electronic message transmission is a PRIVATE communication which contains
information which may be confidential or privileged. The information is intended
to be for the use of the individual or entity named above. If you are not the
intended recipient, please be aware that any disclosure, copying, distribution
or use of the contents of this information is prohibited. Please notify the
sender of the delivery error by replying to this message, or notify us by
telephone (877-633-2436, ext. 0), and then delete it from your system.

This electronic message transmission is a PRIVATE communication which contains
information which may be confidential or privileged. The information is intended
to be for the use of the individual or entity named above. If you are not the
intended recipient, please be aware that any disclosure, copying, distribution
or use of the contents of this information is prohibited. Please notify the
sender of the delivery error by replying to this message, or notify us by
telephone (877-633-2436, ext. 0), and then delete it from your system.

****************************************************************
Ce message a ete transmis par Internet. Son emetteur peut ne pas etre
l'emetteur annonce. Son contenu et toute piece jointe peuvent ne pas etre exacts.
This message originated from the Internet. Its originator may or may not be who they claim to be and information contained in the message and any attachments may or may not be accurate.
$!1$!

Les informations contenues dans ce message sont confidentielles et peuvent constituer des informations privilegiees. Si vous n etes pas le destinataire de ce message, il vous est interdit de le copier, de le faire suivre, de le divulguer ou d en utiliser tout ou partie. Si vous avez recu ce message par erreur, merci de le supprimer de votre systeme, ainsi que toutes ses copies, et d en avertir immediatement l expediteur par message de retour.
Il est impossible de garantir que les communications par messagerie electronique arrivent en temps utile, sont securisees ou denuees de toute erreur ou virus. En consequence, l expediteur n accepte aucune responsabilite du fait des erreurs ou omissions qui pourraient en resulter.
--- ----------------------------------------------------- ---
The information contained in this e-mail is confidential. It may also be legally privileged. If you are not the addressee you may not copy, forward, disclose or use any part of it. If you have received this message in error, please delete it and all copies from your system and notify the sender immediately by return e-mail.
E-mail communications cannot be guaranteed to be timely secure, error or virus-free. The sender does not accept liability for any errors or omissions which arise as a result.
$!2$!