Index: MANIFEST
===================================================================
--- MANIFEST	(revision 247)
+++ MANIFEST	(working copy)
@@ -47,6 +47,7 @@
 oraperl.ph	Old oraperl file included for completeness of emulation
 t/01base.t
 t/10general.t
+t/15nls.t
 t/20select.t
 t/21nchar.t
 t/25plsql.t
Index: Changes
===================================================================
--- Changes	(revision 247)
+++ Changes	(working copy)
@@ -27,6 +27,7 @@
   Added $dbh->{ora_parse_error_offset} docs thanks to Andy Hassall.
   Added $dbh->reauthenticate($user,$pass) docs thanks to Andy Hassall.
   Corrected typo in ora_lob_read() example thanks to Johannes Wierny.
+  Added $dbh->ora_can_unicode and $dbh->ora_nls_parameters thanks to Andy Hassall.
 
 =head1 Changes in DBD-Oracle 1.15   27th January 2004
 
Index: Oracle.pm
===================================================================
--- Oracle.pm	(revision 247)
+++ Oracle.pm	(working copy)
@@ -66,6 +66,8 @@
 	    DBD::Oracle::db->install_method("ora_lob_append");
 	    DBD::Oracle::db->install_method("ora_lob_trim");
 	    DBD::Oracle::db->install_method("ora_lob_length");
+	    DBD::Oracle::db->install_method("ora_nls_parameters");
+	    DBD::Oracle::db->install_method("ora_can_unicode");
 	}
 
 	$drh;
@@ -848,6 +850,41 @@
 SQL
     }
 
+    sub ora_nls_parameters {
+	my $dbh = shift;
+	my $refresh = shift;
+
+	if ($refresh || !defined $dbh->{ora_nls_parameters}) {
+	    $dbh->{ora_nls_parameters} =
+	      {
+	       map { $_->[0] => $_->[1] }
+	           @{$dbh->selectall_arrayref(q{
+                       SELECT parameter, value FROM v$nls_parameters})}
+	      };
+	}
+
+	return \%{$dbh->{ora_nls_parameters}};
+    }
+
+    sub ora_can_unicode {
+	# 0 = No Unicode support.
+	# 1 = National character set is Unicode-based.
+	# 2 = Database character set is Unicode-based.
+	# 3 = Both character sets are Unicode-based.
+	my $dbh = shift;
+	return $dbh->{ora_can_unicode} if defined $dbh->{ora_can_unicode};
+
+	$dbh->{ora_can_unicode}  = 0;
+
+	$dbh->{ora_can_unicode} += 1
+	  if ($dbh->ora_nls_parameters->{'NLS_NCHAR_CHARACTERSET'} =~ /UTF/);
+
+	$dbh->{ora_can_unicode} += 2
+	  if ($dbh->ora_nls_parameters->{'NLS_CHARACTERSET'} =~ /UTF/);
+
+	return $dbh->{ora_can_unicode};
+    }
+
 }   # end of package DBD::Oracle::db
 
 
@@ -1844,6 +1881,25 @@
 Starts a new session against the current database using the credentials
 supplied.
 
+=item ora_nls_parameters ( [ $refresh ] )
+
+Returns a hash reference containing the current NLS parameters, as given
+by the v$nls_parameters view. The values fetched are cached between calls.
+To cause the latest values to be fetched, pass a true value to the function.
+
+=item ora_can_unicode
+
+Returns a number indicating whether either of the database character sets
+is a Unicode encoding.
+
+0 = Neither character set is a Unicode encoding.
+
+1 = National character set is a Unicode encoding.
+
+2 = Database character set is a Unicode encoding.
+
+3 = Both character sets are Unicode encodings.
+
 =back
 
 
Index: t/15nls.t
===================================================================
--- t/15nls.t	(revision 0)
+++ t/15nls.t	(revision 0)
@@ -0,0 +1,44 @@
+#!perl
+use strict;
+use warnings;
+
+use DBI;
+use Test::More;
+
+my $testcount = 8;
+plan tests => $testcount;
+
+$| = 1;
+
+my $dbuser = $ENV{ORACLE_USERID} || 'scott/tiger';
+
+SKIP :
+{
+    my $dbh = DBI->connect('dbi:Oracle:', $dbuser, '',
+			   {
+			    AutoCommit => 1,
+			    PrintError => 0,
+			   });
+
+    skip "Unable to connect to Oracle ($DBI::errstr)", $testcount
+      unless ($dbh);
+
+    my ($nls_parameters_before, $nls_parameters_after);
+    my $old_date_format = 'HH24:MI:SS DD/MM/YYYY';
+    my $new_date_format = 'YYYYMMDDHH24MISS';
+
+    ok($dbh->do("alter session set nls_date_format='$old_date_format'"), 'set date format');
+
+    like($dbh->ora_can_unicode, qr/^[0123]/,                          'ora_can_unicode');
+
+    ok($nls_parameters_before = $dbh->ora_nls_parameters,             'fetch ora_nls_parameters');
+    is(ref($nls_parameters_before), 'HASH',                           'check ora_nls_parameters returned hashref');
+    is($nls_parameters_before->{'NLS_DATE_FORMAT'}, $old_date_format, 'check returned nls_date_format');
+
+    ok($dbh->do("alter session set nls_date_format='$new_date_format'"), 'alter date format');
+    ok(eq_hash($nls_parameters_before, $dbh->ora_nls_parameters),        'check ora_nls_parameters caches old values');
+
+    is($dbh->ora_nls_parameters(1)->{'NLS_DATE_FORMAT'}, $new_date_format, 'refetch and check new nls_date_format value');
+}
+
+__END__
