File: rt85886.t

package info (click to toggle)
libdbd-oracle-perl 1.74-3
  • links: PTS, VCS
  • area: contrib
  • in suites: stretch
  • size: 1,808 kB
  • ctags: 653
  • sloc: ansic: 8,165; perl: 6,942; makefile: 18
file content (50 lines) | stat: -rwxr-xr-x 1,072 bytes parent folder | download
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
#!/usr/bin/perl -w

use strict;
use warnings;

use Test::More;

use DBI qw(:sql_types);
use Devel::Peek;
use B qw( svref_2object SVf_IOK SVf_NOK SVf_POK );

unshift @INC ,'t';
require 'nchar_test_lib.pl';

sub is_iv {
   my $sv = svref_2object(my $ref = \$_[0]);
   my $flags = $sv->FLAGS;

   # See http://www.perlmonks.org/?node_id=971411
   my $x = $sv->can('PV') ? $sv->PV : undef;

   if (wantarray) {
       return ($flags & SVf_IOK, $x);
   } else {
       return $flags & SVf_IOK;
   }
}

my $dsn = oracle_test_dsn();
my $dbuser = $ENV{ORACLE_USERID} || 'scott/tiger';

my $dbh = DBI->connect( $dsn, $dbuser, '',  {
    PrintError => 0, FetchHashKeyName =>'NAME_lc'});

plan skip_all => "unable to connect to Oracle database" if not $dbh;

plan tests => 2;

my $s = $dbh->prepare(q/select 1 as one from dual/);
$s->execute;

$s->bind_col (1, undef, {TYPE => SQL_INTEGER, DiscardString => 1});

my $list = $s->fetchall_arrayref({});

is($list->[0]{one}, 1, "correct value returned");
ok(is_iv($list->[0]{one}), "ivok") or Dump($list->[0]{one});

$dbh->disconnect;