line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::DBI::Informix; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
9
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
159
|
|
4
|
|
|
|
|
|
|
require Class::DBI; |
5
|
2
|
|
|
2
|
|
11
|
use base qw(Class::DBI); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
2954
|
|
6
|
2
|
|
|
2
|
|
131715
|
use vars qw($VERSION); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
847
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
$VERSION = '1.4'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Class::DBI::Informix - Class::DBI extension for Informix |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 SYNOPSIS |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use strict; |
17
|
|
|
|
|
|
|
use base qw(Class::DBI::Informix); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
__PACKAGE__->set_db(Main => 'dbi:Informix:stores'); |
20
|
|
|
|
|
|
|
__PACKAGE__->set_up_table('customer'); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 DESCRIPTION |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
This module implements a sub class of L that provides for |
25
|
|
|
|
|
|
|
some of the quirks of the Informix databases. You should probably be |
26
|
|
|
|
|
|
|
using this module rather than L if you are working with an |
27
|
|
|
|
|
|
|
Informix database. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
It provides one public method set_up_table() that will setup the columns |
30
|
|
|
|
|
|
|
and the primary key for the specified table. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub _croak |
35
|
|
|
|
|
|
|
{ |
36
|
0
|
|
|
0
|
|
|
require Carp; |
37
|
0
|
|
|
|
|
|
Carp::croak(@_); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=over 2 |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=item set_up_table |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Determines the Primary key and column names for the given table |
45
|
|
|
|
|
|
|
will be called by Class::DBI::Loader |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=back |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub set_up_table |
52
|
|
|
|
|
|
|
{ |
53
|
0
|
|
|
0
|
1
|
|
my ( $class, $table ) = @_; |
54
|
0
|
|
|
|
|
|
my $dbh = $class->db_Main; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# DBIs primary_key_info doesn't work for informix |
57
|
|
|
|
|
|
|
# Oh yes the storage of indexes really is that nasty |
58
|
0
|
|
|
|
|
|
my $sth = $dbh->prepare(<<"SQL"); |
59
|
|
|
|
|
|
|
SELECT p1.colname, |
60
|
|
|
|
|
|
|
p2.colname, |
61
|
|
|
|
|
|
|
p3.colname, |
62
|
|
|
|
|
|
|
p4.colname, |
63
|
|
|
|
|
|
|
p5.colname, |
64
|
|
|
|
|
|
|
p6.colname, |
65
|
|
|
|
|
|
|
p7.colname, |
66
|
|
|
|
|
|
|
p8.colname, |
67
|
|
|
|
|
|
|
p9.colname, |
68
|
|
|
|
|
|
|
p10.colname, |
69
|
|
|
|
|
|
|
p11.colname, |
70
|
|
|
|
|
|
|
p12.colname, |
71
|
|
|
|
|
|
|
p13.colname, |
72
|
|
|
|
|
|
|
p14.colname, |
73
|
|
|
|
|
|
|
p15.colname |
74
|
|
|
|
|
|
|
from sysconstraints |
75
|
|
|
|
|
|
|
join systables |
76
|
|
|
|
|
|
|
on sysconstraints.tabid = systables.tabid |
77
|
|
|
|
|
|
|
join sysindexes on sysconstraints.idxname = sysindexes.idxname |
78
|
|
|
|
|
|
|
left outer join syscolumns as p1 on p1.colno = sysindexes.part1 and p1.tabid = systables.tabid |
79
|
|
|
|
|
|
|
left outer join syscolumns as p2 on p2.colno = sysindexes.part2 and p2.tabid = systables.tabid |
80
|
|
|
|
|
|
|
left outer join syscolumns as p3 on p3.colno = sysindexes.part3 and p3.tabid = systables.tabid |
81
|
|
|
|
|
|
|
left outer join syscolumns as p4 on p4.colno = sysindexes.part4 and p4.tabid = systables.tabid |
82
|
|
|
|
|
|
|
left outer join syscolumns as p5 on p5.colno = sysindexes.part5 and p5.tabid = systables.tabid |
83
|
|
|
|
|
|
|
left outer join syscolumns as p6 on p6.colno = sysindexes.part6 and p6.tabid = systables.tabid |
84
|
|
|
|
|
|
|
left outer join syscolumns as p7 on p7.colno = sysindexes.part7 and p7.tabid = systables.tabid |
85
|
|
|
|
|
|
|
left outer join syscolumns as p8 on p8.colno = sysindexes.part8 and p8.tabid = systables.tabid |
86
|
|
|
|
|
|
|
left outer join syscolumns as p9 on p9.colno = sysindexes.part9 and p9.tabid = systables.tabid |
87
|
|
|
|
|
|
|
left outer join syscolumns as p10 on p10.colno = sysindexes.part10 and p10.tabid = systables.tabid |
88
|
|
|
|
|
|
|
left outer join syscolumns as p11 on p11.colno = sysindexes.part11 and p11.tabid = systables.tabid |
89
|
|
|
|
|
|
|
left outer join syscolumns as p12 on p12.colno = sysindexes.part12 and p12.tabid = systables.tabid |
90
|
|
|
|
|
|
|
left outer join syscolumns as p13 on p13.colno = sysindexes.part13 and p13.tabid = systables.tabid |
91
|
|
|
|
|
|
|
left outer join syscolumns as p14 on p14.colno = sysindexes.part14 and p14.tabid = systables.tabid |
92
|
|
|
|
|
|
|
left outer join syscolumns as p15 on p15.colno = sysindexes.part15 and p15.tabid = systables.tabid |
93
|
|
|
|
|
|
|
where systables.tabname = ? |
94
|
|
|
|
|
|
|
and constrtype = 'P' |
95
|
|
|
|
|
|
|
SQL |
96
|
0
|
|
|
|
|
|
$sth->execute($table); |
97
|
0
|
|
|
|
|
|
my @primary = grep { defined $_ } $sth->fetchrow_array; |
|
0
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
$sth->finish; |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
$sth = $dbh->prepare(<<"SQL"); |
101
|
|
|
|
|
|
|
select colname |
102
|
|
|
|
|
|
|
from systables |
103
|
|
|
|
|
|
|
join syscolumns on syscolumns.tabid = systables.tabid |
104
|
|
|
|
|
|
|
where systables.tabname = ? |
105
|
|
|
|
|
|
|
SQL |
106
|
0
|
|
|
|
|
|
$sth->execute($table); |
107
|
0
|
|
|
|
|
|
my @cols = map { $_->[0] } @{$sth->fetchall_arrayref}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
$sth->finish; |
109
|
|
|
|
|
|
|
|
110
|
0
|
0
|
|
|
|
|
_croak("$table has no primary key") unless @primary; |
111
|
0
|
|
|
|
|
|
$class->table($table); |
112
|
0
|
|
|
|
|
|
$class->columns( Primary => @primary ); |
113
|
0
|
|
|
|
|
|
$class->columns( All => @cols ); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
# It appears that none of the methods that DBI::Class uses to |
117
|
|
|
|
|
|
|
# obtain the last serial value work. |
118
|
|
|
|
|
|
|
sub _auto_increment_value |
119
|
|
|
|
|
|
|
{ |
120
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
121
|
0
|
|
|
|
|
|
my $dbh = $self->db_Main(); |
122
|
|
|
|
|
|
|
|
123
|
0
|
0
|
|
|
|
|
my $id = $dbh->{ix_sqlerrd}[1] |
124
|
|
|
|
|
|
|
or $self->_croak("Can't get last insert id"); |
125
|
|
|
|
|
|
|
|
126
|
0
|
|
|
|
|
|
return $id; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 BUGS |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
This has only tested with IDS 9.40.UC2E1 and 10.UC5 and could well be using |
133
|
|
|
|
|
|
|
specific features of those databases. If reporting a bug please |
134
|
|
|
|
|
|
|
specify the server version that use are using. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 SUPPORT |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
All bug reports and patches should be made via RT at: |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
bug-Class-DBI-Loader-Informix@rt.cpan.org |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
That way I'm less likely to ignore them. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 SEE ALSO |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
L L L |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 AUTHOR |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Jonathan Stowe |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 LICENSE |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
This library is free software - it comes with no warranty whatsoever. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Copyright (c) 2006 Jonathan Stowe |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
This module can be distributed under the same terms as Perl itself |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=cut |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
1; |