| 1 | package MPMinus::Store::Oracle; # $Id: Oracle.pm 122 2013-05-07 13:05:41Z minus $ | ||
| 2 | use strict; | ||
| 3 | |||
| 4 | =head1 NAME | ||
| 5 | |||
| 6 | MPMinus::Store::Oracle - Oracle | ||
| 7 | |||
| 8 | =head1 VERSION | ||
| 9 | |||
| 10 | Version 1.51 | ||
| 11 | |||
| 12 | =head1 SYNOPSIS | ||
| 13 | |||
| 14 | use MPMinus::Store::Oracle; | ||
| 15 | |||
| 16 | # Oracle connect | ||
| 17 | my $oracle = new MPMinus::Store::Oracle ( | ||
| 18 | -m => $m, # OPTIONAL | ||
| 19 | -host => '192.168.1.1', | ||
| 20 | -database => 'TEST', | ||
| 21 | -user => 'login', | ||
| 22 | -pass => 'password', | ||
| 23 | -attr => { | ||
| 24 | RaiseError => 0, | ||
| 25 | PrintError => 0, | ||
| 26 | }, | ||
| 27 | ) | ||
| 28 | |||
| 29 | my $dbh = $oracle->connect; | ||
| 30 | |||
| 31 | my $pingstat = $oracle->ping if $oracle; | ||
| 32 | |||
| 33 | # Table select (as array) | ||
| 34 | my @result = $oracle->table($sql, @inargs); | ||
| 35 | |||
| 36 | # Table select (as hash) | ||
| 37 | my %result = $oracle->tableh($key, $sql, @inargs); # $key - primary index field name | ||
| 38 | |||
| 39 | # Record (as array) | ||
| 40 | my @result = $oracle->record($sql, @inargs); | ||
| 41 | |||
| 42 | # Record (as hash) | ||
| 43 | my %result = $oracle->recordh($sql, @inargs); | ||
| 44 | |||
| 45 | # Fiels (as scalar) | ||
| 46 | my $result = $oracle->field($sql, @inargs); | ||
| 47 | |||
| 48 | # SQL/PL-SQL | ||
| 49 | my $sth = $oracle->execute($sql, @inargs); | ||
| 50 | ... | ||
| 51 | $sth->finish; | ||
| 52 | |||
| 53 | =head1 DESCRIPTION | ||
| 54 | |||
| 55 | Oracle Database independent interface for MPMinus on MPMinus::Store::DBI based. | ||
| 56 | |||
| 57 | See L<MPMinus::Store::DBI> | ||
| 58 | |||
| 59 | =head1 EXAMPLE | ||
| 60 | |||
| 61 | use MPMinus::Store::Oracle; | ||
| 62 | |||
| 63 | my $oracle = new MPMinus::Store::Oracle ( | ||
| 64 | -name => 'mylocaldb', | ||
| 65 | -user => 'root', | ||
| 66 | -password => 'password' | ||
| 67 | ); | ||
| 68 | |||
| 69 | my @table = $oracle->table("select * from tablename where date = ?", "01.01.2000") | ||
| 70 | |||
| 71 | =head1 HISTORY | ||
| 72 | |||
| 73 | =over 8 | ||
| 74 | |||
| 75 | =item B<1.00 / 11.04.2007> | ||
| 76 | |||
| 77 | Init version | ||
| 78 | |||
| 79 | =item B<1.10 / 26.03.2008> | ||
| 80 | |||
| 81 | OOP style supported | ||
| 82 | |||
| 83 | =item B<1.20 / 01.04.2008> | ||
| 84 | |||
| 85 | Module movied to global level | ||
| 86 | |||
| 87 | =item B<1.40 / 27.02.2009> | ||
| 88 | |||
| 89 | Module movied to MPMinus level | ||
| 90 | |||
| 91 | =item B<1.51 / 19.04.2010> | ||
| 92 | |||
| 93 | Added in MPMinus poject | ||
| 94 | |||
| 95 | =item B<1.41 / Wed Apr 24 14:53:38 2013 MSK> | ||
| 96 | |||
| 97 | General refactoring | ||
| 98 | |||
| 99 | =back | ||
| 100 | |||
| 101 | =head1 SEE ALSO | ||
| 102 | |||
| 103 | L<MPMinus::Store::DBI>, L<CTK::DBI>, L<Apache::DBI>, L<DBI> | ||
| 104 | |||
| 105 | =head1 AUTHOR | ||
| 106 | |||
| 107 | Serz Minus (Lepenkov Sergey) L<http://serzik.ru> E<lt>minus@mail333.comE<gt> | ||
| 108 | |||
| 109 | =head1 COPYRIGHT | ||
| 110 | |||
| 111 | Copyright (C) 1998-2013 D&D Corporation. All Rights Reserved | ||
| 112 | |||
| 113 | =head1 LICENSE | ||
| 114 | |||
| 115 | This program is free software: you can redistribute it and/or modify | ||
| 116 | it under the terms of the GNU General Public License as published by | ||
| 117 | the Free Software Foundation, either version 3 of the License, or | ||
| 118 | (at your option) any later version. | ||
| 119 | |||
| 120 | This program is distributed in the hope that it will be useful, | ||
| 121 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 122 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 123 | GNU General Public License for more details. | ||
| 124 | |||
| 125 | See C<LICENSE> file | ||
| 126 | |||
| 127 | =cut | ||
| 128 | |||
| 129 | use vars qw($VERSION); | ||
| 130 | $VERSION = 1.52; | ||
| 131 | |||
| 132 | use MPMinus::Store::DBI; | ||
| 133 | use CTK::Util qw/ :API /; | ||
| 134 | |||
| 135 | sub new { | ||
| 136 | my $class = shift; | ||
| 137 | my @in = read_attributes(MPMinus::Store::DBI::ATTR_NAMES,@_); | ||
| 138 | my %args = ( | ||
| 139 | -driver => 'Oracle', | ||
| 140 | -m => $in[0], | ||
| 141 | -host => $in[2], | ||
| 142 | -name => $in[3], | ||
| 143 | -user => $in[5], | ||
| 144 | -pass => $in[6], | ||
| 145 | -attr => $in[10], | ||
| 146 | ); | ||
| 147 | return new MPMinus::Store::DBI(%args); | ||
| 148 | } | ||
| 149 | |||
| 150 | 1; |