File: 21nchar.t

package info (click to toggle)
libdbd-oracle-perl 1.80-2
  • links: PTS, VCS
  • area: contrib
  • in suites: bullseye
  • size: 1,800 kB
  • sloc: ansic: 8,354; perl: 7,843; xml: 442; makefile: 18
file content (73 lines) | stat: -rw-r--r-- 2,113 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!perl
#written by Lincoln A Baxter (lab@lincolnbaxter.com)

use strict;
use warnings;

use lib 't/lib';
use DBDOracleTestLib qw/ db_handle show_db_charsets set_nls_nchar test_data
                         insert_test_count select_test_count show_test_data
                         drop_table create_table insert_rows dump_table select_rows
                         force_drop_table
/;

use Test::More;
use DBI qw(:sql_types);
use DBD::Oracle qw(:ora_types ORA_OCI SQLCS_NCHAR );

my $dbh;
$| = 1;
SKIP: {
    plan skip_all =>
      'Unable to run 8bit char test, perl version is less than 5.6'
      unless ( $] >= 5.006 );

    $dbh = db_handle();

    #  $dbh->{PrintError} = 1;
    plan skip_all => 'Unable to connect to Oracle' unless $dbh;

    note("Testing control and 8 bit chars...\n");
    note("Database and client versions and character sets:\n");
    show_db_charsets($dbh);

    plan skip_all => 'Oracle charset tests unreliable for Oracle 8 client'
      if ORA_OCI() < 9.0 and !$ENV{DBD_ALL_TESTS};

    # get the database NCHARSET before we begin... if it is not UTF, then
    # use it as the client side ncharset, otherwise, use WE8ISO8859P1
    my $ncharset = $dbh->ora_nls_parameters()->{'NLS_NCHAR_CHARACTERSET'};
    $dbh->disconnect();    # we want to start over with the ncharset we select
    undef $dbh;

    if ( $ncharset =~ m/UTF/i ) {
        $ncharset = 'WE8ISO8859P1';    #WE8MSWIN1252
    }
    set_nls_nchar( $ncharset, 1 );
    $dbh = db_handle();

    my $tdata     = test_data('narrow_nchar');
    my $testcount = 0                            #create table
      + insert_test_count($tdata) + select_test_count($tdata) * 1;

    plan tests => $testcount;
    show_test_data( $tdata, 0 );

    force_drop_table($dbh);
    create_table( $dbh, $tdata );
    insert_rows( $dbh, $tdata, SQLCS_NCHAR );
    dump_table( $dbh, 'nch', 'descr' );
    select_rows( $dbh, $tdata );

    #    view_with_sqlplus(1,$tcols) if $ENV{DBD_NCHAR_SQLPLUS_VIEW};
    #    view_with_sqlplus(0,$tcols) if $ENV{DBD_NCHAR_SQLPLUS_VIEW};
}

END {
    eval {
        drop_table($dbh)
    };
}

__END__