| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package SQL::Query::Limit::Oracle; |
|
2
|
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
7388
|
use warnings; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
97
|
|
|
4
|
3
|
|
|
3
|
|
18
|
use strict; |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
140
|
|
|
5
|
3
|
|
|
3
|
|
19
|
use vars qw($VERSION); |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
160
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$VERSION = '0.01'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
16
|
use Abstract::Meta::Class ':all'; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
734
|
|
|
10
|
3
|
|
|
3
|
|
16
|
use SQL::Entity::Column ':all'; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
262
|
|
|
11
|
3
|
|
|
3
|
|
20
|
use SQL::Entity::Condition ':all'; |
|
|
3
|
|
|
|
|
14
|
|
|
|
3
|
|
|
|
|
342
|
|
|
12
|
3
|
|
|
3
|
|
15
|
use base 'SQL::Entity'; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
2405
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 NAME |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
SQL::Query::Limit::Oracle - LIMIT emulation for Oracle database. |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
use SQL::Query::Limit::Oracle; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
SQL navigation wrapper for Oracle. |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head2 EXPORT |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
None. |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 ATTRIBUTES |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=over |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=item the_rownum |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
has '$.the_rownum'; |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=back |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 METHODS |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=over |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=item query |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub query { |
|
53
|
4
|
|
|
4
|
1
|
57
|
my ($self, $offset, $limit, $requested_columns, $condition) = @_; |
|
54
|
4
|
|
|
|
|
12
|
$condition = $self->limit_clause($offset, $limit, $condition); |
|
55
|
4
|
|
|
|
|
35
|
my ($sql, $bind_variables) = $self->SUPER::query($requested_columns, $condition); |
|
56
|
4
|
|
|
|
|
15
|
$sql = "SELECT " . $self->alias . ".*" |
|
57
|
|
|
|
|
|
|
. "\nFROM (\n" . $sql . ") " . $self->alias |
|
58
|
|
|
|
|
|
|
. "\nWHERE the_rownum >= ?"; |
|
59
|
4
|
|
|
|
|
59
|
push @$bind_variables, $offset; |
|
60
|
4
|
|
|
|
|
36
|
($sql, $bind_variables); |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=item limit_clause |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=cut |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub limit_clause { |
|
69
|
4
|
|
|
4
|
1
|
7
|
my ($self, $offset, $limit, $condition) = @_; |
|
70
|
4
|
|
|
|
|
6
|
my $result; |
|
71
|
4
|
|
|
|
|
11
|
my $to_rownum = $offset + $limit; |
|
72
|
4
|
50
|
|
|
|
12
|
if($condition) { |
|
73
|
0
|
|
|
|
|
0
|
$result = sql_cond('the_rownum', '<', $to_rownum)->and($condition); |
|
74
|
|
|
|
|
|
|
} else { |
|
75
|
4
|
|
|
|
|
17
|
$result = sql_cond('the_rownum', '<', $to_rownum); |
|
76
|
|
|
|
|
|
|
} |
|
77
|
4
|
|
|
|
|
9
|
$result; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=item selectable_columns |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub selectable_columns { |
|
86
|
4
|
|
|
4
|
1
|
24
|
my ($self, $requested_columns) = @_; |
|
87
|
4
|
|
|
|
|
8
|
($self->the_rownum_column, $self->SUPER::selectable_columns($requested_columns)) |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item the_rownum_column |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub the_rownum_column { |
|
96
|
8
|
|
|
8
|
1
|
11
|
my ($self) = @_; |
|
97
|
8
|
|
|
|
|
20
|
my $the_rownum = $self->the_rownum; |
|
98
|
8
|
|
66
|
|
|
113
|
$the_rownum ||= $self->the_rownum(SQL::Entity::Column->new(name => 'ROWNUM', id => 'the_rownum')); |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item query_columns |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Returns query column for the object. |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=cut |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub query_columns { |
|
109
|
4
|
|
|
4
|
1
|
8
|
my ($self) = @_; |
|
110
|
4
|
|
|
|
|
12
|
(the_rownum => $self->the_rownum_column, $self->SUPER::query_columns); |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item query_setup |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=cut |
|
117
|
|
|
|
|
|
|
|
|
118
|
0
|
|
|
0
|
1
|
0
|
sub query_setup {} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item order_by_clause |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Returns " ORDER BY ..." SQL fragment |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub order_by_clause { |
|
128
|
4
|
|
|
4
|
1
|
91
|
my ($self) = @_; |
|
129
|
4
|
100
|
|
|
|
13
|
my $index = $self->index or return ""; |
|
130
|
2
|
100
|
|
|
|
35
|
return "" if $index->hint; |
|
131
|
1
|
|
|
|
|
12
|
" ORDER BY " . $index->order_by_operand($self); |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item select_hint_clause |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Return hinst cluase that will be placed as SELECT operand |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=cut |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub select_hint_clause { |
|
142
|
4
|
|
|
4
|
1
|
9
|
my ($self) = @_; |
|
143
|
4
|
100
|
|
|
|
28
|
my $index = $self->index or return ""; |
|
144
|
2
|
100
|
|
|
|
40
|
return "" unless $index->hint; |
|
145
|
1
|
|
|
|
|
12
|
"/*+ " . $index->hint . " */ "; |
|
146
|
|
|
|
|
|
|
} |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
1; |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
__END__ |