简体   繁体   中英

Perl script to connect oracle database

I am new to Perl Programming and database connectivity. Can anyone please let me know step by step procedure to write Perl Script for Oracle Database connectivity.

My Perl Verion is:

This is perl 5, version 22, subversion 0 (v5.22.0) built for MSWin32-x64-multi-thread
Copyright 1987-2015, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit.

I have tried the below:

my $db = DBI->connect("dbi:Oracle:Local","SYSTEM","SYSTEM") or die print ("could not connect! $DBI::errstr \n");

Since I don't know what is this "dbi:Oracle:Local" I could not able to connect to Database.

Can you please let me know what is dbi, Oracle, local. if it is Hostname and oracle database name, how can I find the same in my computer.

Do I need to set any ENV variable in Perl? If so, where and what I need to set?

dbi:Oracle lets DBI know which driver to use. If you're connecting to an Oracle database, you'll never change these.

Local is either an actual database name on the local system, or a name listed in TNSNAMES.ORA . Substitute the name of the local database you'd like to connect to.

The next two parameters are username and password.

If you're connecting remotely, or need to do something more elaborate, consult the docs , or one of the many available guides .

my $db = DBI->connect("dbi:Oracle:Local","SYSTEM","SYSTEM");

"dbi" is a string,
"Oracle" is the driver type,
"local" is the database name,
First "SYSTEM" is the username and second one is password.

use DBI;
my $dbh = DBI->connect( "dbi:Oracle:databaseName", 'username', 'passwd' ) or die($DBI::errstr, "\n");

First read the basic concept of Simple Database access using Perl DBI and SQL .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM