| 1 | =head1 NAME | ||
| 2 | |||
| 3 | DBIx::SQLEngine::Driver::Informix - Support DBD::Informix and DBD::ODBC/Informix | ||
| 4 | |||
| 5 | =head1 SYNOPSIS | ||
| 6 | |||
| 7 | B<DBI Wrapper>: Adds methods to a DBI database handle. | ||
| 8 | |||
| 9 | my $sqldb = DBIx::SQLEngine->new( 'dbi:Informix:test_data@my_server' ); | ||
| 10 | |||
| 11 | B<Portability Subclasses:> Uses driver's idioms or emulation. | ||
| 12 | |||
| 13 | $sqldb->do_insert( # use SERIAL 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 Informix's idiosyncrasies. | ||
| 22 | |||
| 23 | =head2 About Driver Subclasses | ||
| 24 | |||
| 25 | 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. | ||
| 26 | |||
| 27 | For more information about the underlying driver class, see L<DBD::Informix>. | ||
| 28 | |||
| 29 | =head2 Under Development | ||
| 30 | |||
| 31 | Note that this driver class has been added recently and not yet tested in real-world conditions. | ||
| 32 | |||
| 33 | To Do: Add missing functionality from related CPAN modules. See L<DBD::Informix::Summary>, L<DBIx::SearchBuilder::Handle::Informix> and maybe L<Dimedis::SqlDriver::Informix>. | ||
| 34 | |||
| 35 | =cut | ||
| 36 | |||
| 37 | ######################################################################## | ||
| 38 | |||
| 39 | package DBIx::SQLEngine::Driver::Informix; | ||
| 40 | |||
| 41 | use strict; | ||
| 42 | use Carp; | ||
| 43 | |||
| 44 | ######################################################################## | ||
| 45 | |||
| 46 | ######################################################################## | ||
| 47 | |||
| 48 | =head1 FETCHING DATA (SQL DQL) | ||
| 49 | |||
| 50 | =head2 Methods Used By Complex Queries | ||
| 51 | |||
| 52 | =over 4 | ||
| 53 | |||
| 54 | =item sql_limit() | ||
| 55 | |||
| 56 | Not yet supported. Perhaps we should use "first $maxrows" and throw out the first $offset? | ||
| 57 | |||
| 58 | =back | ||
| 59 | |||
| 60 | =cut | ||
| 61 | |||
| 62 | sub sql_limit { | ||
| 63 | confess("Not yet supported") | ||
| 64 | } | ||
| 65 | |||
| 66 | ######################################################################## | ||
| 67 | |||
| 68 | ######################################################################## | ||
| 69 | |||
| 70 | =head1 EDITING DATA (SQL DML) | ||
| 71 | |||
| 72 | =head2 Insert to Add Data | ||
| 73 | |||
| 74 | =over 4 | ||
| 75 | |||
| 76 | =item do_insert_with_sequence() | ||
| 77 | |||
| 78 | $sqldb->do_insert_with_sequence( $sequence_name, %sql_clauses ) : $row_count | ||
| 79 | |||
| 80 | Implemented using _seq_do_insert_postfetch and seq_fetch_current. | ||
| 81 | |||
| 82 | =item seq_fetch_current() | ||
| 83 | |||
| 84 | $sqldb->seq_fetch_current( ) : $current_value | ||
| 85 | |||
| 86 | Implemented using DBD::Informix's ix_sqlerrd attribute. | ||
| 87 | |||
| 88 | Note that this doesn't fetch the current sequence value for a given | ||
| 89 | table, since it doesn't respect the table and field arguments, but | ||
| 90 | merely returns the last sequencial value created during this session. | ||
| 91 | |||
| 92 | =back | ||
| 93 | |||
| 94 | =cut | ||
| 95 | |||
| 96 | # $rows = $self->do_insert_with_sequence( $sequence, %clauses ); | ||
| 97 | sub do_insert_with_sequence { | ||
| 98 | (shift)->_seq_do_insert_postfetch( @_ ) | ||
| 99 | } | ||
| 100 | |||
| 101 | # $current_id = $sqldb->seq_fetch_current( ); | ||
| 102 | sub seq_fetch_current { | ||
| 103 | my $self = shift; | ||
| 104 | |||
| 105 | $self->get_dbh->{ix_sqlerrd}[1] | ||
| 106 | } | ||
| 107 | |||
| 108 | ######################################################################## | ||
| 109 | |||
| 110 | ######################################################################## | ||
| 111 | |||
| 112 | =head1 DEFINING STRUCTURES (SQL DDL) | ||
| 113 | |||
| 114 | =head2 Column Type Methods | ||
| 115 | |||
| 116 | =over 4 | ||
| 117 | |||
| 118 | =item dbms_create_column_types() | ||
| 119 | |||
| 120 | $sqldb->dbms_create_column_types () : %column_type_codes | ||
| 121 | |||
| 122 | Implemented using Informix's byte and SERIAL types. | ||
| 123 | |||
| 124 | =item dbms_create_column_text_long_type() | ||
| 125 | |||
| 126 | $sqldb->dbms_create_column_text_long_type () : $col_type_str | ||
| 127 | |||
| 128 | Implemented using Informix's text type. | ||
| 129 | |||
| 130 | =back | ||
| 131 | |||
| 132 | =cut | ||
| 133 | |||
| 134 | sub dbms_create_column_types { | ||
| 135 | 'sequential' => 'SERIAL', | ||
| 136 | 'binary' => 'byte', | ||
| 137 | } | ||
| 138 | |||
| 139 | sub dbms_create_column_text_long_type { | ||
| 140 | 'text' | ||
| 141 | } | ||
| 142 | |||
| 143 | ######################################################################## | ||
| 144 | |||
| 145 | ######################################################################## | ||
| 146 | |||
| 147 | =head1 ADVANCED CAPABILITIES | ||
| 148 | |||
| 149 | =head2 Call, Create and Drop Stored Procedures | ||
| 150 | |||
| 151 | =over 4 | ||
| 152 | |||
| 153 | =item fetch_storedproc() | ||
| 154 | |||
| 155 | $sqldb->fetch_storedproc( $proc_name, @arguments ) : $rows | ||
| 156 | |||
| 157 | Calls fetch_sql with "execute procedure", the procedure name, and the arguments using placeholders. | ||
| 158 | |||
| 159 | =item do_storedproc() | ||
| 160 | |||
| 161 | $sqldb->do_storedproc( $proc_name, @arguments ) : $row_count | ||
| 162 | |||
| 163 | Calls do_sql with "execute procedure", the procedure name, and the arguments using placeholders. | ||
| 164 | |||
| 165 | =item create_storedproc() | ||
| 166 | |||
| 167 | $sqldb->create_storedproc( $proc_name, $definition ) | ||
| 168 | |||
| 169 | Calls do_sql with "create procedure", the procedure name, and the definition. | ||
| 170 | |||
| 171 | =item drop_storedproc() | ||
| 172 | |||
| 173 | $sqldb->drop_storedproc( $proc_name ) | ||
| 174 | |||
| 175 | Calls do_sql with "drop procedure" and the procedure name. | ||
| 176 | |||
| 177 | =back | ||
| 178 | |||
| 179 | =cut | ||
| 180 | |||
| 181 | sub fetch_storedproc { | ||
| 182 | (shift)->fetch_sql( "execute procedure " . (shift) . | ||
| 183 | "(" . join(', ', ('?') x scalar(@_) ) . ")", @_) | ||
| 184 | } | ||
| 185 | sub do_storedproc { | ||
| 186 | (shift)->do_sql( "execute procedure " . (shift) . | ||
| 187 | "(" . join(', ', ('?') x scalar(@_) ) . ")", @_) | ||
| 188 | } | ||
| 189 | sub create_storedproc { | ||
| 190 | (shift)->do_sql( "create procedure $_[0] " . join("\n", @_ ) ) | ||
| 191 | } | ||
| 192 | sub drop_storedproc { | ||
| 193 | (shift)->do_sql( "drop procedure $_[0]" ) | ||
| 194 | } | ||
| 195 | |||
| 196 | ######################################################################## | ||
| 197 | |||
| 198 | =head1 SEE ALSO | ||
| 199 | |||
| 200 | See L<DBIx::SQLEngine> for the overall interface and developer documentation. | ||
| 201 | |||
| 202 | See L<DBIx::SQLEngine::Docs::ReadMe> for general information about | ||
| 203 | this distribution, including installation and license information. | ||
| 204 | |||
| 205 | =cut | ||
| 206 | |||
| 207 | ######################################################################## | ||
| 208 | |||
| 209 | 1; |