SQLEngine/Driver/Sybase.pm untested

filter: Statementstmt 0.0% 0 / 15 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 28 CC 1 SCAR 6.9
CC
1
Cov
0%
sql_limit
2.0
do_insert_with_sequence
2.0
seq_fetch_current
2.0
CRAP 2.0
1 =head1 NAME
2  
3 DBIx::SQLEngine::Driver::Sybase - Extends SQLEngine for DBMS Idiosyncrasies
4  
5 =head1 SYNOPSIS
6  
7 B<DBI Wrapper>: Adds methods to a DBI database handle.
8  
9 my $sqldb = DBIx::SQLEngine->new( 'dbi:Sybase:server=MyServer' );
10  
11 B<Portability Subclasses:> Uses driver's idioms or emulation.
12  
13 $sqldb->do_insert( # use identity column
14 table => 'students', sequence => 'id',
15 values => { 'name'=>'Dave', 'age'=>'19', 'status'=>'minor' },
16 );
17  
18  
19 =head1 DESCRIPTION
20  
21 This package provides a subclass of DBIx::SQLEngine which compensates for Sybase's idiosyncrasies.
22  
23 =head2 Under Development
24  
25 Note: this driver class has been added recently and not yet tested in real-world conditions.
26  
27 The SQLEngine framework doesn't yet have a strategy or interface for dealing with one of the limitations of DBD::Sybase: each connection can only have one statement handle active. If AutoCommit is on, then it silently opens up another database handle for each additional statement handle. However, transactions can't span connections, so if AutoCommit is off, it dies with this message: C<DBD::Sybase: Can't have multiple statement handles on a single database handle when AutoCommit is OFF>.
28  
29 =head2 About Driver Subclasses
30  
31 You do not need to use this package directly; when you connect to a database, the SQLEngine object is automatically re-blessed in to the appropriate subclass.
32  
33 For more information about the underlying driver class, see L<DBD::Sybase>.
34  
35 =cut
36  
37 ########################################################################
38  
39 package DBIx::SQLEngine::Driver::Sybase;
40  
41 use strict;
42 use Carp;
43  
44 ########################################################################
45  
46 =head2 About DBMS Flavors
47  
48 This driver uses the DatabaseFlavors trait. For more information, see L<DBIx::SQLEngine::Driver::Trait::DatabaseFlavors>.
49  
50 It does this in order to support use of DBD::Sybase with Microsoft SQL Server. For more information, see L< DBIx::SQLEngine::Driver::Sybase::MySQL>.
51  
52 =cut
53  
54 use DBIx::SQLEngine::Driver::Trait::DatabaseFlavors ':all';
55  
56 ########################################################################
57  
58 ########################################################################
59  
60 =head1 FETCHING DATA (SQL DQL)
61  
62 =head2 Methods Used By Complex Queries
63  
64 =over 4
65  
66 =item sql_limit()
67  
68 Not yet supported.
69  
70 See http://www.isug.com/Sybase_FAQ/ASE/section6.2.html#6.2.12
71  
72 =back
73  
74 =cut
75  
76 sub sql_limit {
77 confess("Not yet supported")
78 }
79  
80 ########################################################################
81  
82 ########################################################################
83  
84 =head1 EDITING DATA (SQL DML)
85  
86 =head2 Insert to Add Data
87  
88 =over 4
89  
90 =item do_insert_with_sequence()
91  
92 $sqldb->do_insert_with_sequence( $sequence_name, %sql_clauses ) : $row_count
93  
94 Implemented using _seq_do_insert_postfetch and seq_fetch_current.
95  
96 =item seq_fetch_current()
97  
98 $sqldb->seq_fetch_current( ) : $current_value
99  
100 Implemented using Sybase's "select @@IDENTITY".
101  
102 Note that this doesn't fetch the current sequence value for a given
103 table, since it doesn't respect the table and field arguments, but
104 merely returns the last sequencial value created during this session.
105  
106 For more information see http://www.isug.com/Sybase_FAQ/ASE/section6.2.html#6.2.9
107  
108 =back
109  
110 =cut
111  
112 # $rows = $self->do_insert_with_sequence( $sequence, %clauses );
113 sub do_insert_with_sequence {
114 (shift)->_seq_do_insert_postfetch( @_ )
115 }
116  
117 # $current_id = $sqldb->seq_fetch_current( );
118 sub seq_fetch_current {
119 my ($self, $table, $field) = @_;
120 $self->fetch_one_value(
121 sql => 'select @@IDENTITY AS lastID'
122 );
123 }
124  
125 ########################################################################
126  
127 ########################################################################
128  
129 =head1 DEFINING STRUCTURES (SQL DDL)
130  
131 =head2 Column Type Methods
132  
133 =over 4
134  
135 =item dbms_create_column_types()
136  
137 $sqldb->dbms_create_column_types () : %column_type_codes
138  
139 Implemented using Sybase's blob and identity types.
140  
141 =item dbms_create_column_text_long_type()
142  
143 $sqldb->dbms_create_column_text_long_type () : $col_type_str
144  
145 Implemented using Sybase's blob type.
146  
147 =back
148  
149 =cut
150  
151 sub dbms_create_column_types {
152 'sequential' => 'numeric(5,0) identity',
153 'binary' => 'blob',
154 }
155  
156 sub dbms_create_column_text_long_type {
157 'blob'
158 }
159  
160 ########################################################################
161  
162 =head1 SEE ALSO
163  
164 See L<DBIx::SQLEngine> for the overall interface and developer documentation.
165  
166 See L<DBIx::SQLEngine::Docs::ReadMe> for general information about
167 this distribution, including installation and license information.
168  
169 =cut
170  
171 ########################################################################
172  
173 1;