Oracle B12255-01 Benutzerhandbuch

Seite von 224
mod_perl
Oracle HTTP Server Modules
7-17
You can access the DBI scripts from the following locations:
http://<hostname.domain>:<port>/cgi-bin/<scriptname>
http://<hostname.domain>:<port>/perl/<scriptname>
If the script specifies “use Apache::DBI” instead of “use DBI”, then it will only
be able to run from
http://<hostname.domain>:<port>/perl/<scriptname>
.
Testing Database Connection
The following is a sample Perl script for testing the database connection of a local
seed database. To use the script to test another database connection, you must
replace scott/tiger with the user name and password for the target database.
Example 7–2
Sample Perl Script For Testing Connection for Local Seed Database
##### Perl script start ######
use DBI;
print "Content-type: text/plain\n\n";
$dbh = DBI->connect("dbi:Oracle:", "scott/tiger", "") || die $DBI::errstr;
 $stmt = $dbh->prepare("select * from emp order by empno")|| die $DBI::errstr;
$rc = $stmt->execute() || die $DBI::errstr;
while (($empno, $name) = $stmt->fetchrow()) { print "$empno $name\n"; }
warn $DBI::errstr if $DBI::err;
die "fetch error: " . $DBI::errstr if $DBI::err;
$stmt->finish() || die "can't close cursor";
$dbh->disconnect() || die "cant't log off Oracle";
##### Perl script End ######
Using SQL NCHAR Datatypes
SQL NCHAR
 datatypes have been refined in Oracle9i, and are now called reliable
Unicode datatypes. SQL NCHAR datatypes such as NCHAR, NVARCHAR2 and NCLOB
allow you to store any Unicode characters regardless of the database character set.
The character set for those datatypes is specified by the national character set,
which is either AL16UTF-16 or UTF8.
See Also:
Oracle9i documentation for more about SQL NCHAR
datatypes.