.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "DBIx::Class::Storage::DBI::Sybase::ASE 3pm" .TH DBIx::Class::Storage::DBI::Sybase::ASE 3pm "2022-05-21" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" DBIx::Class::Storage::DBI::Sybase::ASE \- Sybase ASE SQL Server support for DBIx::Class .SH "SYNOPSIS" .IX Header "SYNOPSIS" This subclass supports DBD::Sybase for real (non-Microsoft) Sybase databases. .SH "DESCRIPTION" .IX Header "DESCRIPTION" If your version of Sybase does not support placeholders, then your storage will be reblessed to DBIx::Class::Storage::DBI::Sybase::ASE::NoBindVars. You can also enable that driver explicitly, see the documentation for more details. .PP With this driver there is unfortunately no way to get the \f(CW\*(C`last_insert_id\*(C'\fR without doing a \f(CW\*(C`SELECT MAX(col)\*(C'\fR. This is done safely in a transaction (locking the table.) See \*(L"\s-1INSERTS WITH PLACEHOLDERS\*(R"\s0. .PP A recommended connect_info setting: .PP .Vb 1 \& on_connect_call => [[\*(Aqdatetime_setup\*(Aq], [\*(Aqblob_setup\*(Aq, log_on_update => 0]] .Ve .SH "METHODS" .IX Header "METHODS" .SS "connect_call_blob_setup" .IX Subsection "connect_call_blob_setup" Used as: .PP .Vb 1 \& on_connect_call => [ [ \*(Aqblob_setup\*(Aq, log_on_update => 0 ] ] .Ve .PP Does \f(CW\*(C`$dbh\->{syb_binary_images} = 1;\*(C'\fR to return \f(CW\*(C`IMAGE\*(C'\fR data as raw binary instead of as a hex string. .PP Recommended. .PP Also sets the \f(CW\*(C`log_on_update\*(C'\fR value for blob write operations. The default is \&\f(CW1\fR, but \f(CW0\fR is better if your database is configured for it. .PP See \&\*(L"Handling \s-1IMAGE/TEXT\s0 data with \fBsyb_ct_get_data()\fR/\fBsyb_ct_send_data()\fR\*(R" in DBD::Sybase. .SS "connect_call_datetime_setup" .IX Subsection "connect_call_datetime_setup" Used as: .PP .Vb 1 \& on_connect_call => \*(Aqdatetime_setup\*(Aq .Ve .PP In connect_info to set: .PP .Vb 2 \& $dbh\->syb_date_fmt(\*(AqISO_strict\*(Aq); # output fmt: 2004\-08\-21T14:36:48.080Z \& $dbh\->do(\*(Aqset dateformat mdy\*(Aq); # input fmt: 08/13/1979 18:08:55.080 .Ve .PP This works for both \f(CW\*(C`DATETIME\*(C'\fR and \f(CW\*(C`SMALLDATETIME\*(C'\fR columns, note that \&\f(CW\*(C`SMALLDATETIME\*(C'\fR columns only have minute precision. .SH "Schema::Loader Support" .IX Header "Schema::Loader Support" As of version \f(CW0.05000\fR, DBIx::Class::Schema::Loader should work well with most versions of Sybase \s-1ASE.\s0 .SH "FreeTDS" .IX Header "FreeTDS" This driver supports DBD::Sybase compiled against FreeTDS () to the best of our ability, however it is recommended that you recompile DBD::Sybase against the Sybase Open Client libraries. They are a part of the Sybase \s-1ASE\s0 distribution: .PP The Open Client \s-1FAQ\s0 is here: . .PP Sybase \s-1ASE\s0 for Linux (which comes with the Open Client libraries) may be downloaded here: . .PP To see if you're using FreeTDS run: .PP .Vb 1 \& perl \-MDBI \-le \*(Aqmy $dbh = DBI\->connect($dsn, $user, $pass); print $dbh\->{syb_oc_version}\*(Aq .Ve .PP It is recommended to set \f(CW\*(C`tds version\*(C'\fR for your \s-1ASE\s0 server to \f(CW5.0\fR in \&\f(CW\*(C`/etc/freetds/freetds.conf\*(C'\fR. .PP Some versions or configurations of the libraries involved will not support placeholders, in which case the storage will be reblessed to DBIx::Class::Storage::DBI::Sybase::ASE::NoBindVars. .PP In some configurations, placeholders will work but will throw implicit type conversion errors for anything that's not expecting a string. In such a case, the \f(CW\*(C`auto_cast\*(C'\fR option from DBIx::Class::Storage::DBI::AutoCast is automatically set, which you may enable on connection with connect_call_set_auto_cast. The type info for the \f(CW\*(C`CAST\*(C'\fRs is taken from the \&\*(L"data_type\*(R" in DBIx::Class::ResultSource definitions in your Result classes, and are mapped to a Sybase type (if it isn't already) using a mapping based on SQL::Translator. .PP In other configurations, placeholders will work just as they do with the Sybase Open Client libraries. .PP Inserts or updates of \s-1TEXT/IMAGE\s0 columns will \fB\s-1NOT\s0\fR work with FreeTDS. .SH "INSERTS WITH PLACEHOLDERS" .IX Header "INSERTS WITH PLACEHOLDERS" With placeholders enabled, inserts are done in a transaction so that there are no concurrency issues with getting the inserted identity value using \&\f(CW\*(C`SELECT MAX(col)\*(C'\fR, which is the only way to get the \f(CW\*(C`IDENTITY\*(C'\fR value in this mode. .PP In addition, they are done on a separate connection so that it's possible to have active cursors when doing an insert. .PP When using \f(CW\*(C`DBIx::Class::Storage::DBI::Sybase::ASE::NoBindVars\*(C'\fR transactions are unnecessary and not used, as there are no concurrency issues with \f(CW\*(C`SELECT @@IDENTITY\*(C'\fR which is a session variable. .SH "TRANSACTIONS" .IX Header "TRANSACTIONS" Due to limitations of the \s-1TDS\s0 protocol and DBD::Sybase, you cannot begin a transaction while there are active cursors, nor can you use multiple active cursors within a transaction. An active cursor is, for example, a ResultSet that has been executed using \f(CW\*(C`next\*(C'\fR or \&\f(CW\*(C`first\*(C'\fR but has not been exhausted or reset. .PP For example, this will not work: .PP .Vb 9 \& $schema\->txn_do(sub { \& my $rs = $schema\->resultset(\*(AqBook\*(Aq); \& while (my $result = $rs\->next) { \& $schema\->resultset(\*(AqMetaData\*(Aq)\->create({ \& book_id => $result\->id, \& ... \& }); \& } \& }); .Ve .PP This won't either: .PP .Vb 2 \& my $first_row = $large_rs\->first; \& $schema\->txn_do(sub { ... }); .Ve .PP Transactions done for inserts in \f(CW\*(C`AutoCommit\*(C'\fR mode when placeholders are in use are not affected, as they are done on an extra database handle. .PP Some workarounds: .IP "\(bu" 4 use DBIx::Class::Storage::DBI::Replicated .IP "\(bu" 4 connect another Schema .IP "\(bu" 4 load the data from your cursor with \*(L"all\*(R" in DBIx::Class::ResultSet .SH "MAXIMUM CONNECTIONS" .IX Header "MAXIMUM CONNECTIONS" The \s-1TDS\s0 protocol makes separate connections to the server for active statements in the background. By default the number of such connections is limited to 25, on both the client side and the server side. .PP This is a bit too low for a complex DBIx::Class application, so on connection the client side setting is set to \f(CW256\fR (see \*(L"maxConnect\*(R" in DBD::Sybase.) You can override it to whatever setting you like in the \s-1DSN.\s0 .PP See for information on changing the setting on the server side. .SH "DATES" .IX Header "DATES" See \*(L"connect_call_datetime_setup\*(R" to setup date formats for DBIx::Class::InflateColumn::DateTime. .SH "LIMITED QUERIES" .IX Header "LIMITED QUERIES" Because \s-1ASE\s0 does not have a good way to limit results in \s-1SQL\s0 that works for all types of queries, the limit dialect is set to GenericSubQ. .PP Fortunately, \s-1ASE\s0 and DBD::Sybase support cursors properly, so when GenericSubQ is too slow you can use the software_limit DBIx::Class::ResultSet attribute to simulate limited queries by skipping over records. .SH "TEXT/IMAGE COLUMNS" .IX Header "TEXT/IMAGE COLUMNS" DBD::Sybase compiled with FreeTDS will \fB\s-1NOT\s0\fR allow you to insert or update \&\f(CW\*(C`TEXT/IMAGE\*(C'\fR columns. .PP Setting \f(CW\*(C`$dbh\->{LongReadLen}\*(C'\fR will also not work with FreeTDS use either: .PP .Vb 1 \& $schema\->storage\->dbh\->do("SET TEXTSIZE $bytes"); .Ve .PP or .PP .Vb 1 \& $schema\->storage\->set_textsize($bytes); .Ve .PP instead. .PP However, the \f(CW\*(C`LongReadLen\*(C'\fR you pass in connect_info is used to execute the equivalent \f(CW\*(C`SET TEXTSIZE\*(C'\fR command on connection. .PP See \*(L"connect_call_blob_setup\*(R" for a connect_info setting you need to work with \f(CW\*(C`IMAGE\*(C'\fR columns. .SH "BULK API" .IX Header "BULK API" The experimental DBD::Sybase Bulk \s-1API\s0 support is used for populate in \fBvoid\fR context, in a transaction on a separate connection. .PP To use this feature effectively, use a large number of rows for each populate call, eg.: .PP .Vb 3 \& while (my $rows = $data_source\->get_100_rows()) { \& $rs\->populate($rows); \& } .Ve .PP \&\fB\s-1NOTE:\s0\fR the add_columns calls in your \f(CW\*(C`Result\*(C'\fR classes \fBmust\fR list columns in database order for this to work. Also, you may have to unset the \f(CW\*(C`LANG\*(C'\fR environment variable before loading your app, as \f(CW\*(C`BCP \-Y\*(C'\fR is not yet supported in DBD::Sybase . .PP When inserting \s-1IMAGE\s0 columns using this method, you'll need to use \&\*(L"connect_call_blob_setup\*(R" as well. .SH "COMPUTED COLUMNS" .IX Header "COMPUTED COLUMNS" If you have columns such as: .PP .Vb 1 \& created_dtm AS getdate() .Ve .PP represent them in your Result classes as: .PP .Vb 6 \& created_dtm => { \& data_type => undef, \& default_value => \e\*(Aqgetdate()\*(Aq, \& is_nullable => 0, \& inflate_datetime => 1, \& } .Ve .PP The \f(CW\*(C`data_type\*(C'\fR must exist and must be \f(CW\*(C`undef\*(C'\fR. Then empty inserts will work on tables with such columns. .SH "TIMESTAMP COLUMNS" .IX Header "TIMESTAMP COLUMNS" \&\f(CW\*(C`timestamp\*(C'\fR columns in Sybase \s-1ASE\s0 are not really timestamps, see: . .PP They should be defined in your Result classes as: .PP .Vb 5 \& ts => { \& data_type => \*(Aqtimestamp\*(Aq, \& is_nullable => 0, \& inflate_datetime => 0, \& } .Ve .PP The \f(CW\*(C`> is necessary if you use DBIx::Class::InflateColumn::DateTime, and most people do, and still want to be able to read these values. .PP The values will come back as hexadecimal. .SH "TODO" .IX Header "TODO" .IP "\(bu" 4 Transitions to AutoCommit=0 (starting a transaction) mode by exhausting any active cursors, using eager cursors. .IP "\(bu" 4 Real limits and limited counts using stored procedures deployed on startup. .IP "\(bu" 4 Blob update with a \s-1LIKE\s0 query on a blob, without invalidating the \s-1WHERE\s0 condition. .IP "\(bu" 4 bulk_insert using prepare_cached (see comments.) .SH "FURTHER QUESTIONS?" .IX Header "FURTHER QUESTIONS?" Check the list of additional \s-1DBIC\s0 resources. .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This module is free software copyright by the DBIx::Class (\s-1DBIC\s0) authors. You can redistribute it and/or modify it under the same terms as the DBIx::Class library.