DBI-BabyConnect

 view release on metacpan or  search on metacpan

lib/DBI/BabyConnect.pm  view on Meta::CPAN

where the $where condition apply. You can specify a reference to an array of array
to be expanded with the new data rows. The method returns a reference to the array
that holds the final results.

 fetchTdaAA() method takes the following arguments:

 1- table name
 2- what to select that follows the SELECT keyword
 3- condition that follows the WHERE keyword
 4- optional array reference that is extended with the new elements being selected. If no array reference
   is passed, then a new array is created within this method to hold the result. The method returns
   a reference to the array that holds the final results; otherwise, it returns undef in case there is no result.
 5- binding parameters

For example to fetch data from the FR_XDRTABLE1 table where ID < 54 AND FLD1='u4_1'

    my $xdr = fetchTdaAA('FR_XDRTABLE1', ' * '  ,  " ID < ? AND FLD1 = ? ",54,'u4_1')

See eg/fetchTdaAA.pl for an example.

=head2 fetchTdaAO

  fetchTdaAO( $table, $selection, $where ,$ahref ,$href ,@bindparams )

The method fetchTdaAO() retrieves object records of data using fetchrow_hashref

 fetchTdaAO() takes the following arguments:

 1- the table name
 2- what to select from the table, that is what will follow the SELECT keyword. This parameter type will determine
   the type of the array reference being returned by this method as shown below:

    Selection                                          Return
    ------------------------------------------         -----------------
    a literal: "ID,UID,TMD0,FLD1,CHANGEDATE_T"         Array of Objects
    a wildcard * literal :  " * "                      Array of Objects
    a hash ref: {...}                                  Array of Objects
    an array: ('ID','UID','TMD0')                      Array of Array (preserving the order)

 3- condition that follows the WHERE keyword
 4- An optional array reference set by the caller, allowing to expand an already allocated array
   with the new records being selected. If no array reference
   is passed, then a new array is created within this method to hold the result. The method returns
   a reference to the array that holds the final results; otherwise, it returns undef in case there is no result.
 5- binding parameters

See eg/fetchTdaAO.pl for an example.

=head1 Closing Functions

Because DBI::BabyConnect objects are live objects that are connected to data sources, programmers
can invoke methods to execute SQL transactions on the data sources.

After you have executed a SQL transaction with a DBI::BabyConnect object, usually DBI requires
that you end the transaction by committing if it passes, by rolling back or raising error if it
fails, by calling finish on the cursor, and by disconnecting the handle.

However DBI::BabyConnect objects are designed to be persisted and to be pooled
within an application. Programmers, 
do not need to call any of the functions aforementioned because 
DBI::BabyConnect will do that transparently for you. You use DBI::BabyConnect so that
you can work with an object whose connection is persisted to a data source, and
the object will do all clean up upon object destruction.

The following functions are provided so that if you chose to port an application that
uses DBI directly, you can easily make use of DBI::BabyConnect without making extensive changes
to the application.

=head2 commit

Call commit() on the handle open by DBI::BabyConnect object. This method is provided to ease
portability of programs using DBI directly.

=head2 rollback

rollback() delegates the rollback to DBI::rollback method, except that the localization
of DBI variables will take place prior to calling DBI::rollback. The localization is necessary
because DBI::BabyConnect allows you to modify the behavior of rollback during run time,
even after you have created a DBI::BabyConnect object.

Usually, you do not need to call the rollback explicitly, as it is being called from other methods (i.e. DBI::BabyConnect::do()
or DBI::BabyConnect::sqlbnd(), etc.) whenever a DBI exeucte() fails and the rollback
conditions are met. Refer to DBI::BabyConnect::do() and ON_FAILED_DBIEXECUTE_ROLLBACK_AND_EXIT
settable variable for more information on how this method is being invoked.

You can always call this method explicitly if you wish to handle the rollback from within
your program.

=head2 finish

Call finish() on the cursor held by DBI::BabyConnect object. Provided to ease portability
of programs using DBI directly.

=head2 disconnect

Call the disconnect() explicitly on a DBI::BabyConnect object, hence delegating the
disconnection to DBI disconnect. You do not need to disconnet during the life time
of a DBI::BabyConnect object, however, if you do so, then you need to C<reconnect> 
by calling C<DBI::BabyConnect::reconnect> if you want to keep on using the same
DBI::BabyConnect object.

disconnect() will call DBI disconnect on the DBI::BabyConnect object. Usually you need
to disconnect the DBI::BabyConnect object from the data source once you are done
working with the object. Yet, you can rely on DBI::BabyConnect to do the disconnection
upon exit or object destruction, by setting C<CALLER_DISCONNECT=0>. Refer to L<"CALLER_DISCONNECT">.


=head1 Error Functions

=head2 dbierror

Returns the $DBI::err as returned by the DBI for the active handle of a DBI::BabyConnect
object. If a DBI::BabyConnect method returns an error then you can check for the
DBI error by calling dbierror(). For example:

  $bbconn-> do($sql) || die $bbconn-> dbierror;

See eg/error_do.pl and eg/error_die.pl.

=head1 Statistical Functions



( run in 1.636 second using v1.01-cache-2.11-cpan-5b529ec07f3 )