=for comment POD_DERIVED_INDEX_GENERATED
The following documentation is automatically generated.  Please do not edit
this file, but rather the original, inline with DBIx::Class::Storage::DBI::Oracle::Generic
at lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm
(on the system that originally ran this).
If you do edit this file, and don't want your changes to be removed, make
sure you change the first line.

=cut

=head1 NAME

DBIx::Class::Storage::DBI::Oracle::Generic - Oracle Support for DBIx::Class

=head1 SYNOPSIS

  # In your result (table) classes
  use base 'DBIx::Class::Core';
  __PACKAGE__->add_columns({ id => { sequence => 'mysequence', auto_nextval => 1 } });
  __PACKAGE__->set_primary_key('id');

  # Somewhere in your Code
  # add some data to a table with a hierarchical relationship
  $schema->resultset('Person')->create ({
        firstname => 'foo',
        lastname => 'bar',
        children => [
            {
                firstname => 'child1',
                lastname => 'bar',
                children => [
                    {
                        firstname => 'grandchild',
                        lastname => 'bar',
                    }
                ],
            },
            {
                firstname => 'child2',
                lastname => 'bar',
            },
        ],
    });

  # select from the hierarchical relationship
  my $rs = $schema->resultset('Person')->search({},
    {
      'start_with' => { 'firstname' => 'foo', 'lastname' => 'bar' },
      'connect_by' => { 'parentid' => { '-prior' => { -ident => 'personid' } },
      'order_siblings_by' => { -asc => 'name' },
    };
  );

  # this will select the whole tree starting from person "foo bar", creating
  # following query:
  # SELECT
  #     me.persionid me.firstname, me.lastname, me.parentid
  # FROM
  #     person me
  # START WITH
  #     firstname = 'foo' and lastname = 'bar'
  # CONNECT BY
  #     parentid = prior personid
  # ORDER SIBLINGS BY
  #     firstname ASC

=head1 DESCRIPTION

This class implements base Oracle support. The subclass
L<DBIx::Class::Storage::DBI::Oracle::WhereJoins> is for C<(+)> joins in Oracle
versions before 9.0.

=head1 METHODS

=head2 get_autoinc_seq

Returns the sequence name for an autoincrement column

=head2 datetime_parser_type

This sets the proper DateTime::Format module for use with
L<DBIx::Class::InflateColumn::DateTime>.

=head2 connect_call_datetime_setup

Used as:

    on_connect_call => 'datetime_setup'

In L<connect_info|DBIx::Class::Storage::DBI/connect_info> to set the session nls
date, and timestamp values for use with L<DBIx::Class::InflateColumn::DateTime>
and the necessary environment variables for L<DateTime::Format::Oracle>, which
is used by it.

Maximum allowable precision is used, unless the environment variables have
already been set.

These are the defaults used:

  $ENV{NLS_DATE_FORMAT}         ||= 'YYYY-MM-DD HH24:MI:SS';
  $ENV{NLS_TIMESTAMP_FORMAT}    ||= 'YYYY-MM-DD HH24:MI:SS.FF';
  $ENV{NLS_TIMESTAMP_TZ_FORMAT} ||= 'YYYY-MM-DD HH24:MI:SS.FF TZHTZM';

To get more than second precision with L<DBIx::Class::InflateColumn::DateTime>
for your timestamps, use something like this:

  use Time::HiRes 'time';
  my $ts = DateTime->from_epoch(epoch => time);

=head2 relname_to_table_alias

L<DBIx::Class> uses L<DBIx::Class::Relationship> names as table aliases in
queries.

Unfortunately, Oracle doesn't support identifiers over 30 chars in length, so
the L<DBIx::Class::Relationship> name is shortened and appended with half of an
MD5 hash.

See L<DBIx::Class::Storage/"relname_to_table_alias">.

=head2 with_deferred_fk_checks

Runs a coderef between:

  alter session set constraints = deferred
  ...
  alter session set constraints = immediate

to defer foreign key checks.

Constraints must be declared C<DEFERRABLE> for this to work.

=head1 ATTRIBUTES

Following additional attributes can be used in resultsets.

=head2 connect_by or connect_by_nocycle

=over 4

=item Value: \%connect_by

=back

A hashref of conditions used to specify the relationship between parent rows
and child rows of the hierarchy.

  connect_by => { parentid => 'prior personid' }

  # adds a connect by statement to the query:
  # SELECT
  #     me.persionid me.firstname, me.lastname, me.parentid
  # FROM
  #     person me
  # CONNECT BY
  #     parentid = prior persionid


  connect_by_nocycle => { parentid => 'prior personid' }

  # adds a connect by statement to the query:
  # SELECT
  #     me.persionid me.firstname, me.lastname, me.parentid
  # FROM
  #     person me
  # CONNECT BY NOCYCLE
  #     parentid = prior persionid

=head2 start_with

=over 4

=item Value: \%condition

=back

A hashref of conditions which specify the root row(s) of the hierarchy.

It uses the same syntax as L<DBIx::Class::ResultSet/search>

  start_with => { firstname => 'Foo', lastname => 'Bar' }

  # SELECT
  #     me.persionid me.firstname, me.lastname, me.parentid
  # FROM
  #     person me
  # START WITH
  #     firstname = 'foo' and lastname = 'bar'
  # CONNECT BY
  #     parentid = prior persionid

=head2 order_siblings_by

=over 4

=item Value: ($order_siblings_by | \@order_siblings_by)

=back

Which column(s) to order the siblings by.

It uses the same syntax as L<DBIx::Class::ResultSet/order_by>

  'order_siblings_by' => 'firstname ASC'

  # SELECT
  #     me.persionid me.firstname, me.lastname, me.parentid
  # FROM
  #     person me
  # CONNECT BY
  #     parentid = prior persionid
  # ORDER SIBLINGS BY
  #     firstname ASC

=head1 INHERITED METHODS

=over 4

=item L<DBIx::Class::Storage::DBI>

L<auto_savepoint|DBIx::Class::Storage::DBI/auto_savepoint>, L<build_datetime_parser|DBIx::Class::Storage::DBI/build_datetime_parser>, L<columns_info_for|DBIx::Class::Storage::DBI/columns_info_for>, L<connect_call_do_sql|DBIx::Class::Storage::DBI/connect_call_do_sql>, L<connect_info|DBIx::Class::Storage::DBI/connect_info>, L<connected|DBIx::Class::Storage::DBI/connected>, L<create_ddl_dir|DBIx::Class::Storage::DBI/create_ddl_dir>, L<datetime_parser|DBIx::Class::Storage::DBI/datetime_parser>, L<datetime_parser_type|DBIx::Class::Storage::DBI/datetime_parser_type>, L<dbh|DBIx::Class::Storage::DBI/dbh>, L<dbh_do|DBIx::Class::Storage::DBI/dbh_do>, L<delete|DBIx::Class::Storage::DBI/delete>, L<deploy|DBIx::Class::Storage::DBI/deploy>, L<disable_sth_caching|DBIx::Class::Storage::DBI/disable_sth_caching>, L<disconnect|DBIx::Class::Storage::DBI/disconnect>, L<disconnect_call_do_sql|DBIx::Class::Storage::DBI/disconnect_call_do_sql>, L<ensure_connected|DBIx::Class::Storage::DBI/ensure_connected>, L<get_dbms_capability|DBIx::Class::Storage::DBI/get_dbms_capability>, L<get_use_dbms_capability|DBIx::Class::Storage::DBI/get_use_dbms_capability>, L<insert|DBIx::Class::Storage::DBI/insert>, L<insert_bulk|DBIx::Class::Storage::DBI/insert_bulk>, L<is_datatype_numeric|DBIx::Class::Storage::DBI/is_datatype_numeric>, L<is_replicating|DBIx::Class::Storage::DBI/is_replicating>, L<lag_behind_master|DBIx::Class::Storage::DBI/lag_behind_master>, L<last_insert_id|DBIx::Class::Storage::DBI/last_insert_id>, L<new|DBIx::Class::Storage::DBI/new>, L<on_connect_call|DBIx::Class::Storage::DBI/on_connect_call>, L<on_connect_do|DBIx::Class::Storage::DBI/on_connect_do>, L<on_disconnect_call|DBIx::Class::Storage::DBI/on_disconnect_call>, L<on_disconnect_do|DBIx::Class::Storage::DBI/on_disconnect_do>, L<select|DBIx::Class::Storage::DBI/select>, L<select_single|DBIx::Class::Storage::DBI/select_single>, L<set_dbms_capability|DBIx::Class::Storage::DBI/set_dbms_capability>, L<set_use_dbms_capability|DBIx::Class::Storage::DBI/set_use_dbms_capability>, L<source_bind_attributes|DBIx::Class::Storage::DBI/source_bind_attributes>, L<sql_limit_dialect|DBIx::Class::Storage::DBI/sql_limit_dialect>, L<sql_maker|DBIx::Class::Storage::DBI/sql_maker>, L<sql_maker_class|DBIx::Class::Storage::DBI/sql_maker_class>, L<sql_name_sep|DBIx::Class::Storage::DBI/sql_name_sep>, L<sql_quote_char|DBIx::Class::Storage::DBI/sql_quote_char>, L<sqlt_type|DBIx::Class::Storage::DBI/sqlt_type>, L<sth|DBIx::Class::Storage::DBI/sth>, L<svp_begin|DBIx::Class::Storage::DBI/svp_begin>, L<svp_release|DBIx::Class::Storage::DBI/svp_release>, L<svp_rollback|DBIx::Class::Storage::DBI/svp_rollback>, L<txn_begin|DBIx::Class::Storage::DBI/txn_begin>, L<txn_commit|DBIx::Class::Storage::DBI/txn_commit>, L<txn_do|DBIx::Class::Storage::DBI/txn_do>, L<txn_rollback|DBIx::Class::Storage::DBI/txn_rollback>, L<unsafe|DBIx::Class::Storage::DBI/unsafe>, L<update|DBIx::Class::Storage::DBI/update>

=item L<DBIx::Class::Storage>

L<cursor|DBIx::Class::Storage/cursor>, L<cursor_class|DBIx::Class::Storage/cursor_class>, L<debug|DBIx::Class::Storage/debug>, L<debugcb|DBIx::Class::Storage/debugcb>, L<debugfh|DBIx::Class::Storage/debugfh>, L<debugobj|DBIx::Class::Storage/debugobj>, L<savepoints|DBIx::Class::Storage/savepoints>, L<schema|DBIx::Class::Storage/schema>, L<set_schema|DBIx::Class::Storage/set_schema>, L<throw_exception|DBIx::Class::Storage/throw_exception>, L<transaction_depth|DBIx::Class::Storage/transaction_depth>, L<txn_scope_guard|DBIx::Class::Storage/txn_scope_guard>

=back

=head1 AUTHOR

See L<DBIx::Class/AUTHOR> and L<DBIx::Class/CONTRIBUTORS>.

=head1 LICENSE

You may distribute this code under the same terms as Perl itself.

