.\" 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::MSSQL 3pm" .TH DBIx::Class::Storage::DBI::MSSQL 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::MSSQL \- Base Class for Microsoft SQL Server support in DBIx::Class .SH "SYNOPSIS" .IX Header "SYNOPSIS" This is the base class for Microsoft \s-1SQL\s0 Server support, used by DBIx::Class::Storage::DBI::ODBC::Microsoft_SQL_Server and DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server. .SH "IMPLEMENTATION NOTES" .IX Header "IMPLEMENTATION NOTES" .SS "\s-1IDENTITY\s0 information" .IX Subsection "IDENTITY information" Microsoft \s-1SQL\s0 Server supports three methods of retrieving the \s-1IDENTITY\s0 value for inserted row: \s-1IDENT_CURRENT,\s0 @@IDENTITY, and \s-1\fBSCOPE_IDENTITY\s0()\fR. \&\s-1SCOPE_IDENTITY\s0 is used here because it is the safest. However, it must be called is the same execute statement, not just the same connection. .PP So, this implementation appends a \s-1SELECT \fBSCOPE_IDENTITY\s0()\fR statement onto each \s-1INSERT\s0 to accommodate that requirement. .PP \&\f(CW\*(C`SELECT @@IDENTITY\*(C'\fR can also be used by issuing: .PP .Vb 1 \& $self\->_identity_method(\*(Aq@@identity\*(Aq); .Ve .PP it will only be used if \s-1\fBSCOPE_IDENTITY\s0()\fR fails. .PP This is more dangerous, as inserting into a table with an on insert trigger that inserts into another table with an identity will give erroneous results on recent versions of \s-1SQL\s0 Server. .SS "identity insert" .IX Subsection "identity insert" Be aware that we have tried to make things as simple as possible for our users. For \s-1MSSQL\s0 that means that when a user tries to create a row, while supplying an explicit value for an autoincrementing column, we will try to issue the appropriate database call to make this possible, namely \f(CW\*(C`SET IDENTITY_INSERT $table_name ON\*(C'\fR. Unfortunately this operation in \s-1MSSQL\s0 requires the \&\f(CW\*(C`db_ddladmin\*(C'\fR privilege, which is normally not included in the standard write-permissions. .SS "Ordered Subselects" .IX Subsection "Ordered Subselects" If you attempted the following query (among many others) in Microsoft \s-1SQL\s0 Server .PP .Vb 5 \& $rs\->search ({}, { \& prefetch => \*(Aqrelation\*(Aq, \& rows => 2, \& offset => 3, \& }); .Ve .PP You may be surprised to receive an exception. The reason for this is a quirk in the \s-1MSSQL\s0 engine itself, and sadly doesn't have a sensible workaround due to the way \s-1DBIC\s0 is built. \s-1DBIC\s0 can do truly wonderful things with the aid of subselects, and does so automatically when necessary. The list of situations when a subselect is necessary is long and still changes often, so it can not be exhaustively enumerated here. The general rule of thumb is a joined has_many relationship with limit/group applied to the left part of the join. .PP In its \*(L"pursuit of standards\*(R" Microsft \s-1SQL\s0 Server goes to great lengths to forbid the use of ordered subselects. This breaks a very useful group of searches like \*(L"Give me things number 4 to 6 (ordered by name), and prefetch all their relations, no matter how many\*(R". While there is a hack which fools the syntax checker, the optimizer may \fBstill elect to break the subselect\fR. Testing has determined that while such breakage does occur (the test suite contains an explicit test which demonstrates the problem), it is relative rare. The benefits of ordered subselects are on the other hand too great to be outright disabled for \s-1MSSQL.\s0 .PP Thus compromise between usability and perfection is the MSSQL-specific resultset attribute \f(CW\*(C`unsafe_subselect_ok\*(C'\fR. It is deliberately not possible to set this on the Storage level, as the user should inspect (and preferably regression-test) the return of every such ResultSet individually. The example above would work if written like: .PP .Vb 6 \& $rs\->search ({}, { \& unsafe_subselect_ok => 1, \& prefetch => \*(Aqrelation\*(Aq, \& rows => 2, \& offset => 3, \& }); .Ve .PP If it is possible to rewrite the \fBsearch()\fR in a way that will avoid the need for this flag \- you are urged to do so. If \s-1DBIC\s0 internals insist that an ordered subselect is necessary for an operation, and you believe there is a different/better way to get the same result \- please file a bugreport. .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.