SPOPS::DBI::Sybase - Sybase-specific routines for the SPOPS::DBI


SPOPS documentation Contained in the SPOPS distribution.

Index


Code Index:

NAME

Top

SPOPS::DBI::Sybase -- Sybase-specific routines for the SPOPS::DBI

SYNOPSIS

Top

 # In your configuration:

 'myspops' => {
     'isa' => [ qw/ SPOPS::DBI::Sybase SPOPS::DBI / ],

     # If you have an IDENTITY field, set increment_field to true...
     'increment_field' => 1,
     # ...and the IDENTITY field in 'no_insert' and 'no_update'
     'no_insert'       => [ 'id' ],
     'no_update'       => [ 'id' ],
     ...
 },

DESCRIPTION

Top

This just implements some Sybase-specific routines so we can abstract them out.

One of them optionally returns the IDENTITY value returned by the last insert. Of course, this only works if you have an IDENTITY field in your table:

 CREATE TABLE my_table (
   id  numeric( 8, 0 ) IDENTITY not null,
   ...
 )

NOTE: You also need to let this module know if you are using this IDENTITY option by setting in your class configuration the key 'increment_field' to a true value.

METHODS

Top

sql_quote

DBD::Sybase depends on the type of a field if you are quoting values to put into a statement, so we override the default 'sql_quote' from SPOPS::SQLInterface to ensure the type of the field is used in the DBI->quote call.

BUGS

Top

Working with FreeTDS

SPOPS works with FreeTDS/MS SQL Server (presumably with FreeTDS/Sybase as well, but it has not been tested). However, there is one hitch: the combination of DBD::Sybase and FreeTDS does not seem to work properly with the standard DBI field type discovery. As a result, you need to specify your datatypes in your SPOPS configuration using the dbi_type_info key:

 my %config = (
       doodad => {
          class          => 'My::Doodad',
          isa            => [ 'SPOPS::DBI::Sybase', 'SPOPS::DBI' ],
          ...,
          dbi_type_info  => { doodad_id => 'int',
                              name      => 'char',
                              action    => 'char' },
       },
 );

See the discussion of "fake types" in SPOPS::DBI::TypeInfo for more information.

TO DO

Top

Nothing known.

SEE ALSO

Top

SPOPS::Key::DBI::Identity

DBD::Sybase

DBI

FreeTDS: http://www.freetds.org/

COPYRIGHT

Top

AUTHORS

Top

Chris Winters <chris@cwinters.com>

See the SPOPS module for the full author list.


SPOPS documentation Contained in the SPOPS distribution.

package SPOPS::DBI::Sybase;

# $Id: Sybase.pm,v 3.6 2004/06/02 00:48:22 lachoy Exp $

use strict;
use SPOPS::Key::DBI::Identity;

$SPOPS::DBI::Sybase::VERSION  = sprintf("%d.%02d", q$Revision: 3.6 $ =~ /(\d+)\.(\d+)/);

sub sql_current_date  { return 'GETDATE()' }

# Backward compatibility and convenience, so you don't have to specify
# another item in the isa -- instead just set 'syb_identity' or
# 'increment_field' to true.

sub post_fetch_id {
    my ( $item, @args ) = @_;
    return undef unless ( $item->CONFIG->{increment_field} or $item->CONFIG->{syb_identity} );
    return SPOPS::Key::DBI::Identity::post_fetch_id( $item, @args );
}


1;

__END__