.\" 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 "Recordset 3pm" .TH Recordset 3pm "2022-06-13" "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::Recordset \- Perl extension for DBI recordsets .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use DBIx::Recordset; \& \& # Setup a new object and select some recods... \& *set = DBIx::Recordset \-> Search ({\*(Aq!DataSource\*(Aq => \*(Aqdbi:Oracle:....\*(Aq, \& \*(Aq!Table\*(Aq => \*(Aqusers\*(Aq, \& \*(Aq$where\*(Aq => \*(Aqname = ? and age > ?\*(Aq, \& \*(Aq$values\*(Aq => [\*(Aqrichter\*(Aq, 25] }) ; \& \& # Get the values of field foo ... \& print "First Records value of foo is $set[0]{foo}\en" ; \& print "Second Records value of foo is $set[1]{foo}\en" ; \& # Get the value of the field age of the current record ... \& print "Age is $set{age}\en" ; \& \& # Do another select with the already created object... \& $set \-> Search ({name => \*(Aqbar\*(Aq}) ; \& \& # Show the result... \& print "All users with name bar:\en" ; \& while ($rec = $set \-> Next) \& { \& print $rec \-> {age} ; \& } \& \& # Setup another object and insert a new record \& *set2 = DBIx::Recordset \-> Insert ({\*(Aq!DataSource\*(Aq => \*(Aqdbi:Oracle:....\*(Aq, \& \*(Aq!Table\*(Aq => \*(Aqusers\*(Aq, \& \*(Aqname\*(Aq => \*(Aqfoo\*(Aq, \& \*(Aqage\*(Aq => 25 }) ; \& \& \& # Update this record (change age from 25 to 99)... \& $set \-> Update ({age => 99}, {name => \*(Aqfoo\*(Aq}) ; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" DBIx::Recordset is a perl module for abstraction and simplification of database access. .PP The goal is to make standard database access (select/insert/update/delete) easier to handle and independend of the underlying \s-1DBMS.\s0 Special attention is made on web applications to make it possible to handle the state-less access and to process the posted data of formfields, but DBIx::Recordset is not limited to web applications. .PP \&\fBDBIx::Recordset\fR uses the \s-1DBI API\s0 to access the database, so it should work with every database for which a \s-1DBD\s0 driver is available (see also DBIx::Compat). .PP Most public functions take a hash reference as parameter, which makes it simple to supply various different arguments to the same function. The parameter hash can also be taken from a hash containing posted formfields like those available with \&\s-1CGI\s0.pm, mod_perl, HTML::Embperl and others. .PP Before using a recordset it is necessary to setup an object. Of course the setup step can be made with the same function call as the first database access, but it can also be handled separately. .PP Most functions which set up an object return a \fBtypglob\fR. A typglob in Perl is an object which holds pointers to all datatypes with the same name. Therefore a typglob must always have a name and \fBcan't\fR be declared with \fBmy\fR. You can only use it as \fBglobal\fR variable or declare it with \fBlocal\fR. The trick for using a typglob is that setup functions can return a \fBreference to an object\fR, an \&\fBarray\fR and a \fBhash\fR at the same time. .PP The object is used to access the object's methods, the array is used to access the records currently selected in the recordset and the hash is used to access the current record. .PP If you don't like the idea of using typglobs you can also set up the object, array and hash separately, or just set the ones you need. .SH "ARGUMENTS" .IX Header "ARGUMENTS" Since most methods take a hash reference as argument, here is a description of the valid arguments first. .SS "Setup Parameters" .IX Subsection "Setup Parameters" All parameters starting with an '!' are only recognized at setup time. If you specify them in later function calls they will be ignored. You can also preset these parameters with the TableAttr method of DBIx::Database. This allows you to presetup most parameters for the whole database and they will be use every time you create a new DBIx::Recordset object, without specifying it every time. .IP "\fB!DataSource\fR" 4 .IX Item "!DataSource" Specifies the database to which to connect. This information can be given in the following ways: .RS 4 .IP "Driver/DB/Host." 4 .IX Item "Driver/DB/Host." Same as the first parameter to the \s-1DBI\s0 connect function. .IP "DBIx::Recordset object" 4 .IX Item "DBIx::Recordset object" Takes the same database handle as the given DBIx::Recordset object. .IP "DBIx::Database object" 4 .IX Item "DBIx::Database object" Takes Driver/DB/Host from the given database object. See DBIx::Database for details about DBIx::Database object. When using more then one Recordset object, this is the most efficient method. .IP "DBIx::Datasbase object name" 4 .IX Item "DBIx::Datasbase object name" Takes Driver/DB/Host from the database object which is saved under the given name ($saveas parameter to DBIx::Database \-> new) .IP "an \s-1DBI\s0 database handle" 4 .IX Item "an DBI database handle" Uses given database handle. .RE .RS 4 .RE .IP "\fB!Table\fR" 4 .IX Item "!Table" Tablename. Multiple tables are comma-separated. .IP "\fB!Username\fR" 4 .IX Item "!Username" Username. Same as the second parameter to the \s-1DBI\s0 connect function. .IP "\fB!Password\fR" 4 .IX Item "!Password" Password. Same as the third parameter to the \s-1DBI\s0 connect function. .IP "\fB!DBIAttr\fR" 4 .IX Item "!DBIAttr" Reference to a hash which holds the attributes for the \s-1DBI\s0 connect function. See perldoc \s-1DBI\s0 for a detailed description. .IP "\fB!Fields\fR" 4 .IX Item "!Fields" Fields which should be returned by a query. If you have specified multiple tables the fieldnames should be unique. If the names are not unique you must specify them along with the tablename (e.g. tab1.field). .Sp \&\s-1NOTE 1:\s0 Fieldnames specified with !Fields can't be overridden. If you plan to use other fields with this object later, use \f(CW$Fields\fR instead. .Sp \&\s-1NOTE 2:\s0 The keys for the returned hash normally don't have a table part. Only the fieldname part forms the key. (See !LongNames for an exception.) .Sp \&\s-1NOTE 3:\s0 Because the query result is returned in a hash, there can only be one out of multiple fields with the same name fetched at once. If you specify multiple fields with the same name, only one is returned from a query. Which one this actually is depends on the \s-1DBD\s0 driver. (See !LongNames for an exception.) .Sp \&\s-1NOTE 4:\s0 Some databases (e.g. mSQL) require you to always qualify a fieldname with a tablename if more than one table is accessed in one query. .IP "\fB!TableFilter\fR" 4 .IX Item "!TableFilter" The TableFilter parameter specifies which tables should be honoured when DBIx::Recordset searches for links between tables (see below). When given as parameter to DBIx::Database it filters for which tables DBIx::Database retrieves metadata. Only thoses tables are used which starts with prefix given by \f(CW\*(C`!TableFilter\*(C'\fR. Also the DBIx::Recordset link detection tries to use this value as a prefix of table names, so you can leave out this prefix when you write a fieldname that should be detected as a link to another table. .IP "\fB!LongNames\fR" 4 .IX Item "!LongNames" When set to 1, the keys of the hash returned for each record not only consist of the fieldnames, but are built in the form table.field. .IP "\fB!Order\fR" 4 .IX Item "!Order" Fields which should be used for ordering any query. If you have specified multiple tables the fieldnames should be unique. If the names are not unique you must specify them among with the tablename (e.g. tab1.field). .Sp \&\s-1NOTE 1:\s0 Fieldnames specified with !Order can't be overridden. If you plan to use other fields with this object later, use \f(CW$order\fR instead. .IP "\fB!TabRelation\fR" 4 .IX Item "!TabRelation" Condition which describes the relation between the given tables (e.g. tab1.id = tab2.id) (See also !TabJoin.) .Sp .Vb 1 \& Example \& \& \*(Aq!Table\*(Aq => \*(Aqtab1, tab2\*(Aq, \& \*(Aq!TabRelation\*(Aq => \*(Aqtab1.id=tab2.id\*(Aq, \& \*(Aqname\*(Aq => \*(Aqfoo\*(Aq \& \& This will generate the following SQL statement: \& \& SELECT * FROM tab1, tab2 WHERE name = \*(Aqfoo\*(Aq and tab1.id=tab2.id ; .Ve .IP "\fB!TabJoin\fR" 4 .IX Item "!TabJoin" !TabJoin allows you to specify an \fB\s-1INNER/RIGHT/LEFT JOIN\s0\fR which is used in a \fB\s-1SELECT\s0\fR statement. (See also !TabRelation.) .Sp .Vb 1 \& Example \& \& \*(Aq!Table\*(Aq => \*(Aqtab1, tab2\*(Aq, \& \*(Aq!TabJoin\*(Aq => \*(Aqtab1 LEFT JOIN tab2 ON (tab1.id=tab2.id)\*(Aq, \& \*(Aqname\*(Aq => \*(Aqfoo\*(Aq \& \& This will generate the following SQL statement: \& \& SELECT * FROM tab1 LEFT JOIN tab2 ON (tab1.id=tab2.id) WHERE name = \&\*(Aqfoo\*(Aq ; .Ve .IP "\fB!PrimKey\fR" 4 .IX Item "!PrimKey" Name of the primary key. When this key appears in a \s-1WHERE\s0 parameter list (see below), DBIx::Recordset will ignore all other keys in the list, speeding up \s-1WHERE\s0 expression preparation and execution. Note that this key does \s-1NOT\s0 have to correspond to a field tagged as \s-1PRIMARY KEY\s0 in a \&\s-1CREATE TABLE\s0 statement. .IP "\fB!Serial\fR" 4 .IX Item "!Serial" Name of the primary key. In contrast to \f(CW\*(C`!PrimKey\*(C'\fR this field is treated as an autoincrement field. If the database does not support autoincrement fields, but sequences the field is set to the next value of a sequence (see \f(CW\*(C`!Sequence\*(C'\fR and \f(CW\*(C`!SeqClass\*(C'\fR) upon each insert. If a \f(CW\*(C`!SeqClass\*(C'\fR is given the values are always retrived from the sequence class regardless if the \s-1DBMS\s0 supports autoincrement or not. The value from this field from the last insert could be retrieved by the function \f(CW\*(C`LastSerial\*(C'\fR. .IP "\fB!Sequence\fR" 4 .IX Item "!Sequence" Name of the sequence to use for this table when inserting a new record and \&\f(CW\*(C`!Serial\*(C'\fR is defind. Defaults to _seq. .IP "\fB!SeqClass\fR" 4 .IX Item "!SeqClass" Name and Parameter for a class that can generate unique sequence values. This is a string that holds comma separated values. The first value is the class name and the following parameters are given to the new constructor. See also \fIDBIx::Recordset::FileSeq\fR and \fIDBIx::Recordset::DBSeq\fR. .Sp Example: '!SeqClass' => 'DBIx::Recordset::FileSeq, /tmp/seq' .IP "\fB!WriteMode\fR" 4 .IX Item "!WriteMode" !WriteMode specifies which write operations to the database are allowed and which are disabled. You may want to set !WriteMode to zero if you only need to query data, to avoid accidentally changing the content of the database. .Sp \&\fB\s-1NOTE:\s0\fR The !WriteMode only works for the DBIx::Recordset methods. If you disable !WriteMode, it is still possible to use \fBdo\fR to send normal \&\s-1SQL\s0 statements to the database engine to write/delete any data. .Sp !WriteMode consists of some flags, which may be added together: .RS 4 .IP "DBIx::Recordset::wmNONE (0)" 4 .IX Item "DBIx::Recordset::wmNONE (0)" Allow \fBno\fR write access to the table(s) .IP "DBIx::Recordset::wmINSERT (1)" 4 .IX Item "DBIx::Recordset::wmINSERT (1)" Allow \s-1INSERT\s0 .IP "DBIx::Recordset::wmUPDATE (2)" 4 .IX Item "DBIx::Recordset::wmUPDATE (2)" Allow \s-1UPDATE\s0 .IP "DBIx::Recordset::wmDELETE (4)" 4 .IX Item "DBIx::Recordset::wmDELETE (4)" Allow \s-1DELETE\s0 .IP "DBIx::Recordset::wmCLEAR (8)" 4 .IX Item "DBIx::Recordset::wmCLEAR (8)" To allow \s-1DELETE\s0 for the whole table, wmDELETE must be also specified. This is necessary for assigning a hash to a hash which is tied to a table. (Perl will first erase the whole table, then insert the new data.) .IP "DBIx::Recordset::wmALL (15)" 4 .IX Item "DBIx::Recordset::wmALL (15)" Allow every access to the table(s) .RE .RS 4 .Sp Default is wmINSERT + wmUPDATE + wmDELETE .RE .IP "\fB!StoreAll\fR" 4 .IX Item "!StoreAll" If present, this will cause DBIx::Recordset to store all rows which will be fetched between consecutive accesses, so it's possible to access data in a random order. (e.g. row 5, 2, 7, 1 etc.) If not specified, rows will only be fetched into memory if requested, which means that you will have to access rows in ascending order. (e.g. 1,2,3 if you try 3,2,4 you will get an undef for row 2 while 3 and 4 is ok) see also \fB\s-1DATA ACCESS\s0\fR below. .IP "\fB!HashAsRowKey\fR" 4 .IX Item "!HashAsRowKey" By default, the hash returned by the setup function is tied to the current record. You can use it to access the fields of the current record. If you set this parameter to true, the hash will by tied to the whole database. This means that the key of the hash will be used as the primary key in the table to select one row. (This parameter only has an effect on functions which return a typglob.) .IP "\fB!IgnoreEmpty\fR" 4 .IX Item "!IgnoreEmpty" This parameter defines how \fBempty\fR and \fBundefined\fR values are handled. The values 1 and 2 may be helpful when using DBIx::Recordset inside a \s-1CGI\s0 script, because browsers send empty formfields as empty strings. .RS 4 .IP "\fB0 (default)\fR" 4 .IX Item "0 (default)" An undefined value is treated as \s-1SQL\s0 \fB\s-1NULL\s0\fR: an empty string remains an empty string. .IP "\fB1\fR" 4 .IX Item "1" All fields with an undefined value are ignored when building the \s-1WHERE\s0 expression. .IP "\fB2\fR" 4 .IX Item "2" All fields with an undefined value or an empty string are ignored when building the \&\s-1WHERE\s0 expression. .RE .RS 4 .Sp \&\fB\s-1NOTE:\s0\fR The default for versions before 0.18 was 2. .RE .IP "\fB!Filter\fR" 4 .IX Item "!Filter" Filters can be used to pre/post\-process the data which is read from/written to the database. The !Filter parameter takes a hash reference which contains the filter functions. If the key is numeric, it is treated as a type value and the filter is applied to all fields of that type. If the key if alphanumeric, the filter is applied to the named field. Every filter description consists of an array with at least two elements. The first element must contain the input function, and the second element must contain the output function. Either may be undef, if only one of them are necessary. The data is passed to the input function before it is written to the database. The input function must return the value in the correct format for the database. The output function is applied to data read from the database before it is returned to the user. .Sp .Vb 1 \& Example: \& \& \*(Aq!Filter\*(Aq => \& { \& DBI::SQL_DATE => \& [ \& sub { shift =~ /(\ed\ed)\e.(\ed\ed)\e.(\ed\ed)/ ; "19$3$2$1"}, \& sub { shift =~ /\ed\ed(\ed\ed)(\ed\ed)(\ed\ed)/ ; "$3.$2.$1"} \& ], \& \& \*(Aqdatefield\*(Aq => \& [ \& sub { shift =~ /(\ed\ed)\e.(\ed\ed)\e.(\ed\ed)/ ; "19$3$2$1"}, \& sub { shift =~ /\ed\ed(\ed\ed)(\ed\ed)(\ed\ed)/ ; "$3.$2.$1"} \& ], \& \& } .Ve .Sp Both filters convert a date in the format dd.mm.yy to the database format 19yymmdd and vice versa. The first one does this for all fields of the type \s-1SQL_DATE,\s0 the second one does this for the fields with the name datefield. .Sp The \fB!Filter\fR parameter can also be passed to the function \fBTableAttr\fR of the \fBDBIx::Database\fR object. In this case it applies to all DBIx::Recordset objects which use these tables. .Sp A third parameter can be optionally specified. It could be set to \f(CW\*(C`DBIx::Recordset::rqINSERT\*(C'\fR, \&\f(CW\*(C`DBIx::Recordset::rqUPDATE\*(C'\fR, or the sum of both. If set, the InputFunction (which is called during \&\s-1UPDATE\s0 or \s-1INSERT\s0) is always called for this field in updates and/or inserts depending on the value. If there is no data specified for this field as an argument to a function which causes an \s-1UPDATE/INSERT,\s0 the InputFunction is called with an argument of \fBundef\fR. .Sp During \s-1UPDATE\s0 and \s-1INSERT\s0 the input function gets either the string 'insert' or 'update' passed as second parameter. .IP "\fB!LinkName\fR" 4 .IX Item "!LinkName" This allows you to get a clear text description of a linked table, instead of (or in addition to) the !LinkField. For example, if you have a record with all your bills, and each record contains a customer number, setting !LinkName DBIx::Recordset can automatically retrieve the name of the customer instead of (or in addition to) the bill record itself. .RS 4 .IP "1 select additional fields" 4 .IX Item "1 select additional fields" This will additionally select all fields given in \fB!NameField\fR of the Link or the table attributes (see TableAttr). .IP "2 build name in uppercase of !MainField" 4 .IX Item "2 build name in uppercase of !MainField" This takes the values of \fB!NameField\fR of the Link or the table attributes (see TableAttr) and joins the content of these fields together into a new field, which has the same name as the !MainField, but in uppercase. .IP "2 replace !MainField with the contents of !NameField" 4 .IX Item "2 replace !MainField with the contents of !NameField" Same as 2, but the !MainField is replaced with \*(L"name\*(R" of the linked record. .RE .RS 4 .Sp See also \fB!Links\fR and \fB\s-1WORKING WITH MULTIPLE TABLES\s0\fR below .RE .IP "\fB!Links\fR" 4 .IX Item "!Links" This parameter can be used to link multiple tables together. It takes a reference to a hash, which has \- as keys, names for a special \fB\*(L"linkfield\*(R"\fR and \- as value, a parameter hash. The parameter hash can contain all the \&\fBSetup parameters\fR. The setup parameters are taken to construct a new recordset object to access the linked table. If !DataSource is omitted (as it normally should be), the same DataSource (and database handle), as the main object is taken. There are special parameters which can only occur in a link definition (see next paragraph). For a detailed description of how links are handled, see \fB\s-1WORKING WITH MULTIPLE TABLES\s0\fR below. .SS "Link Parameters" .IX Subsection "Link Parameters" .IP "\fB!MainField\fR" 4 .IX Item "!MainField" The \fB!MailField\fR parameter holds a fieldname which is used to retrieve a key value for the search in the linked table from the main table. If omitted, it is set to the same value as \fB!LinkedField\fR. .IP "\fB!LinkedField\fR" 4 .IX Item "!LinkedField" The fieldname which holds the key value in the linked table. If omitted, it is set to the same value as \fB!MainField\fR. .IP "\fB!NameField\fR" 4 .IX Item "!NameField" This specifies the field or fields which will be used as a \*(L"name\*(R" for the destination table. It may be a string or a reference to an array of strings. For example, if you link to an address table, you may specify the field \*(L"nickname\*(R" as the name field for that table, or you may use ['name', 'street', 'city']. .Sp Look at \fB!LinkName\fR for more information. .IP "\fB!DoOnConnect\fR" 4 .IX Item "!DoOnConnect" You can give an \s-1SQL\s0 Statement (or an array reference of \s-1SQL\s0 statements), that will be executed every time, just after an connect to the db. As third possibilty you can give an hash reference. After every successful connect, DBIx::Recordset excutes the statements, in the element which corresponds to the name of the driver. '*' is executed for all drivers. .IP "\fB!Default\fR" 4 .IX Item "!Default" Specifies default values for new rows that are inserted via hash or array access. The Insert method ignores this parameter. .IP "\fB!TieRow\fR" 4 .IX Item "!TieRow" Setting this parameter to zero will cause DBIx::Recordset to \fBnot\fR tie the returned rows to an DBIx::Recordset::Row object and instead returns an simple hash. The benefit of this is that it will speed up things, but you aren't able to write to such an row, nor can you use the link feature with such a row. .IP "\fB!Debug\fR" 4 .IX Item "!Debug" Set the debug level. See \s-1DEBUGGING.\s0 .IP "\fB!PreFetch\fR" 4 .IX Item "!PreFetch" Only for tieing a hash! Gives an where expression (either as string or as hashref) that is used to prefetch records from that database. All following accesses to the tied hash only access this prefetched data and don't execute any database queries. See \f(CW\*(C`!Expires\*(C'\fR how to force a refetch. Giving a '*' as value to \f(CW\*(C`!PreFetch\*(C'\fR fetches the whole table into memory. .Sp .Vb 1 \& The following example prefetches all record with id < 7: \& \& tie %dbhash, \*(AqDBIx::Recordset::Hash\*(Aq, {\*(Aq!DataSource\*(Aq => $DSN, \& \*(Aq!Username\*(Aq => $User, \& \*(Aq!Password\*(Aq => $Password, \& \*(Aq!Table\*(Aq => \*(Aqfoo\*(Aq, \& \*(Aq!PreFetch\*(Aq => { \& \*(Aq*id\*(Aq => \*(Aq<\*(Aq, \& \*(Aqid\*(Aq => 7 \& }, \& \*(Aq!PrimKey\*(Aq => \*(Aqid\*(Aq} ; \& \& The following example prefetches all records: \& \& tie %dbhash, \*(AqDBIx::Recordset::Hash\*(Aq, {\*(Aq!DataSource\*(Aq => $DSN, \& \*(Aq!Username\*(Aq => $User, \& \*(Aq!Password\*(Aq => $Password, \& \*(Aq!Table\*(Aq => \*(Aqbar\*(Aq, \& \*(Aq!PreFetch\*(Aq => \*(Aq*\*(Aq, \& \*(Aq!PrimKey\*(Aq => \*(Aqid\*(Aq} ; .Ve .IP "\fB!Expires\fR" 4 .IX Item "!Expires" Only for tieing a hash! If the values is numeric, the prefetched data will be refetched is it is older then the given number of seconds. If the values is a \s-1CODEREF\s0 the function is called and the data is refetched is the function returns true. .IP "\fB!MergeFunc\fR" 4 .IX Item "!MergeFunc" Only for tieing a hash! Gives an reference to an function that is called when more then one record for a given hash key is found to merge the records into one. The function receives a reference to both records a arguments. If more the two records are found, the function is called again for each following record, which is already merged data as first parameter. .Sp .Vb 3 \& The following example sets up a hash, that, when more then one record with the same id is \& found, the field C is added and the first record is returned, where the C field \& contains the sum of B found records: \& \& tie %dbhash, \*(AqDBIx::Recordset::Hash\*(Aq, {\*(Aq!DataSource\*(Aq => $DSN, \& \*(Aq!Username\*(Aq => $User, \& \*(Aq!Password\*(Aq => $Password, \& \*(Aq!Table\*(Aq => \*(Aqbar\*(Aq, \& \*(Aq!MergeFunc\*(Aq => sub { my ($a, $b) = @_ ; $a\->{sum} += $b\->{sum} ; }, \& \*(Aq!PrimKey\*(Aq => \*(Aqid\*(Aq} ; .Ve .SS "Where Parameters" .IX Subsection "Where Parameters" The following parameters are used to build an \s-1SQL WHERE\s0 expression .IP "\fB\f(CB$where\fB\fR" 4 .IX Item "$where" Give an \s-1SQL WHERE\s0 expression literaly. If \f(CW$where\fR is specified, all other where parameters described below are ignored. The only expection is \f(CW$values\fR which can be used to give the values to bind to the placeholders in \f(CW$where\fR .IP "\fB\f(CB$values\fB\fR" 4 .IX Item "$values" Values which should be bound to the placeholders given in \f(CW$where\fR. .Sp .Vb 1 \& Example: \& \& *set = DBIx::Recordset \-> Search ({\*(Aq!DataSource\*(Aq => \*(Aqdbi:Oracle:....\*(Aq, \& \*(Aq!Table\*(Aq => \*(Aqusers\*(Aq, \& \*(Aq$where\*(Aq => \*(Aqname = ? and age > ?\*(Aq, \& \*(Aq$values\*(Aq => [\*(Aqrichter\*(Aq, 25] }) ; .Ve .Sp \&\fB\s-1NOTE:\s0\fR Filters defined with \f(CW\*(C`!Filter\*(C'\fR are \fBnot\fR applied to these values, because DBIx::Recordset has no chance to know with values belongs to which field. .IP "\fB{fieldname}\fR" 4 .IX Item "{fieldname}" Value for field. The value will be quoted automatically, if necessary. The value can also be an array ref in which case the values are put together with the operator passed via \fB\f(CB$valueconj\fB\fR (default: or) .Sp .Vb 1 \& Example: \& \& \*(Aqname\*(Aq => [ \*(Aqmouse\*(Aq, \*(Aqcat\*(Aq] will expand to name=\*(Aqmouse\*(Aq or name=\*(Aqcat\*(Aq .Ve .IP "\fB'{fieldname}\fR" 4 .IX Item "'{fieldname}" Value for field. The value will always be quoted. This is only necessary if DBIx::Recordset cannot determine the correct type for a field. .IP "\fB#{fieldname}\fR" 4 .IX Item "#{fieldname}" Value for field. The value will never be quoted, but will converted a to number. This is only necessary if DBIx::Recordset cannot determine the correct type for a field. .IP "\fB\e{fieldname}\fR" 4 .IX Item "{fieldname}" Value for field. The value will not be converted in any way, i.e. you have to quote it before supplying it to DBIx::Recordset if necessary. .IP "\fB+{fieldname}|{fieldname}..\fR" 4 .IX Item "+{fieldname}|{fieldname}.." Values for multiple fields. The value must be in one/all fields depending on \f(CW$compconj\fR Example: '+name|text' => 'abc' will expand to name='abc' or text='abc' .IP "\fB\f(CB$compconj\fB\fR" 4 .IX Item "$compconj" \&'or' or 'and' (default is 'or'). Specifies the conjunction between multiple fields. (see above) .IP "\fB\f(CB$valuesplit\fB\fR" 4 .IX Item "$valuesplit" Regular expression for splitting a field value in multiple values (default is '\et') The conjunction for multiple values could be specified with \fB\f(CB$valueconj\fB\fR. By default, only one of the values must match the field. .Sp .Vb 2 \& Example: \& \*(Aqname\*(Aq => "mouse\etcat" will expand to name=\*(Aqmouse\*(Aq or name=\*(Aqcat\*(Aq \& \& NOTE: The above example can also be written as \*(Aqname\*(Aq => [ \*(Aqmouse\*(Aq, \*(Aqcat\*(Aq] .Ve .IP "\fB\f(CB$valueconj\fB\fR" 4 .IX Item "$valueconj" \&'or' or 'and' (default is 'or'). Specifies the conjunction for multiple values. .IP "\fB\f(CB$conj\fB\fR" 4 .IX Item "$conj" \&'or' or 'and' (default is 'and') conjunction between fields .IP "\fB\f(CB$operator\fB\fR" 4 .IX Item "$operator" Default operator if not otherwise specified for a field. (default is '=') .IP "\fB*{fieldname}\fR" 4 .IX Item "*{fieldname}" Operator for the named field .Sp .Vb 2 \& Example: \& \*(Aqvalue\*(Aq => 9, \*(Aq*value\*(Aq => \*(Aq>\*(Aq expand to value > 9 .Ve .Sp Could also be an array ref, so you can pass different operators for the values. This is mainly handy when you need to select a range .Sp .Vb 1 \& Example: \& \& $set \-> Search ({id => [5, 7 ], \& \*(Aq*id\*(Aq => [\*(Aq>=\*(Aq, \*(Aq<=\*(Aq], \& \*(Aq$valueconj\*(Aq => \*(Aqand\*(Aq}) ; \& \& This will expanded to "id >= 5 and id <= 7" .Ve .Sp \&\s-1NOTE:\s0 To get a range you need to specify the \f(CW$valueconj\fR parameter as \f(CW\*(C`and\*(C'\fR because it defaults to \f(CW\*(C`or\*(C'\fR. .IP "\fB\f(CB$expr\fB\fR" 4 .IX Item "$expr" \&\fB\f(CB$expr\fB\fR can be used to group parts of the where expression for proper priority. To specify more the one sub expression, add a numerical index to \f(CW$expr\fR (e.g. \f(CW$expr1\fR, \f(CW$expr2\fR) .Sp .Vb 1 \& Example: \& \& $set \-> Search ({id => 5, \& \*(Aq$expr\*(Aq => \& { \& \*(Aqname\*(Aq => \*(AqRichter\*(Aq, \& \*(Aqcountry\*(Aq => \*(Aqde\*(Aq, \& \*(Aq$conj\*(Aq => \*(Aqor\*(Aq \& } \& }) ; \& \& This will expand to \& \& (name = \*(AqRichter\*(Aq or country = \*(Aqde\*(Aq) and id = 5 .Ve .SS "Search parameters" .IX Subsection "Search parameters" .IP "\fB\f(CB$start\fB\fR" 4 .IX Item "$start" First row to fetch. The row specified here will appear as index 0 in the data array. .IP "\fB\f(CB$max\fB\fR" 4 .IX Item "$max" Maximum number of rows to fetch. Every attempt to fetch more rows than specified here will return undef, even if the select returns more rows. .IP "\fB\f(CB$next\fB\fR" 4 .IX Item "$next" Add the number supplied with \fB\f(CB$max\fB\fR to \fB\f(CB$start\fB\fR. This is intended to implement a next button. .IP "\fB\f(CB$prev\fB\fR" 4 .IX Item "$prev" Subtract the number supplied with \fB\f(CB$max\fB\fR from \fB\f(CB$start\fB\fR. This is intended to implement a previous button. .IP "\fB\f(CB$order\fB\fR" 4 .IX Item "$order" Fieldname(s) for ordering (\s-1ORDER BY\s0) (must be comma-separated, could also contain \&\s-1USING\s0) .IP "\fB\f(CB$group\fB\fR" 4 .IX Item "$group" Fieldname(s) for grouping (\s-1GROUP BY\s0) (must be comma-separated, could also contain \&\s-1HAVING\s0). .IP "\fB\f(CB$append\fB\fR" 4 .IX Item "$append" String which is appended to the end of a \s-1SELECT\s0 statement, can contain any data. .IP "\fB\f(CB$fields\fB\fR" 4 .IX Item "$fields" Fields which should be returned by a query. If you have specified multiple tables the fieldnames should be unique. If the names are not unique you must specify them along with the tablename (e.g. tab1.field). .Sp \&\s-1NOTE 1:\s0 If \fB!fields\fR is supplied at setup time, this can not be overridden by \f(CW$fields\fR. .Sp \&\s-1NOTE 2:\s0 The keys for the returned hash normally don't have a table part. Only the fieldname part forms the key. (See !LongNames for an exception.) .Sp \&\s-1NOTE 3:\s0 Because the query result is returned in a hash, there can only be one out of multiple fields with the same name fetched at once. If you specify multiple fields with same name, only one is returned from a query. Which one this actually is, depends on the \s-1DBD\s0 driver. (See !LongNames for an exception.) .IP "\fB\f(CB$primkey\fB\fR" 4 .IX Item "$primkey" Name of primary key. DBIx::Recordset assumes that if specified, this is a unique key to the given table(s). DBIx::Recordset can not verify this. You are responsible for specifying the right key. If such a primary exists in your table, you should specify it here, because it helps DBIx::Recordset optimize the building of \s-1WHERE\s0 expressions. .Sp See also \fB!PrimKey\fR .SS "Execute parameters" .IX Subsection "Execute parameters" The following parameters specify which action is to be executed: .IP "\fB=search\fR" 4 .IX Item "=search" search data .IP "\fB=update\fR" 4 .IX Item "=update" update record(s) .IP "\fB=insert\fR" 4 .IX Item "=insert" insert record .IP "\fB=delete\fR" 4 .IX Item "=delete" delete record(s) .IP "\fB=empty\fR" 4 .IX Item "=empty" setup empty object .SH "METHODS" .IX Header "METHODS" .IP "\fB*set = DBIx::Recordset \-> Setup (\e%params)\fR" 4 .IX Item "*set = DBIx::Recordset -> Setup (%params)" Setup a new object and connect it to a database and table(s). Collects information about the tables which are needed later. Returns a typglob which can be used to access the object ($set), an array (@set) and a hash (%set). .Sp \&\fBparams:\fR setup .IP "\fB\f(CB$set\fB = DBIx::Recordset \-> SetupObject (\e%params)\fR" 4 .IX Item "$set = DBIx::Recordset -> SetupObject (%params)" Same as above, but setup only the object, do not tie anything (no array, no hash) .Sp \&\fBparams:\fR setup .IP "\fB\f(CB$set\fB = tie \f(CB@set\fB, 'DBIx::Recordset', \f(CB$set\fB\fR" 4 .IX Item "$set = tie @set, 'DBIx::Recordset', $set" .PD 0 .IP "\fB\f(CB$set\fB = tie \f(CB@set\fB, 'DBIx::Recordset', \e%params\fR" 4 .IX Item "$set = tie @set, 'DBIx::Recordset', %params" .PD Ties an array to a recordset object. The result of a query which is executed by the returned object can be accessed via the tied array. If the array contents are modified, the database is updated accordingly (see Data access below for more details). The first form ties the array to an already existing object, the second one setup a new object. .Sp \&\fBparams:\fR setup .IP "\fB\f(CB$set\fB = tie \f(CB%set\fB, 'DBIx::Recordset::Hash', \f(CB$set\fB\fR" 4 .IX Item "$set = tie %set, 'DBIx::Recordset::Hash', $set" .PD 0 .IP "\fB\f(CB$set\fB = tie \f(CB%set\fB, 'DBIx::Recordset::Hash', \e%params\fR" 4 .IX Item "$set = tie %set, 'DBIx::Recordset::Hash', %params" .PD Ties a hash to a recordset object. The hash can be used to access/update/insert single rows of a table: the hash key is identical to the primary key value of the table. (see Data access below for more details) .Sp The first form ties the hash to an already existing object, the second one sets up a new object. .Sp \&\fBparams:\fR setup .IP "\fB\f(CB$set\fB = tie \f(CB%set\fB, 'DBIx::Recordset::CurrRow', \f(CB$set\fB\fR" 4 .IX Item "$set = tie %set, 'DBIx::Recordset::CurrRow', $set" .PD 0 .IP "\fB\f(CB$set\fB = tie \f(CB%set\fB, 'DBIx::Recordset::CurrRow', \e%params\fR" 4 .IX Item "$set = tie %set, 'DBIx::Recordset::CurrRow', %params" .PD Ties a hash to a recordset object. The hash can be used to access the fields of the current record of the recordset object. (See Data access below for more details.) .Sp The first form ties the hash to an already existing object, the second one sets up a new object. .Sp \&\fBparams:\fR setup .IP "\fB*set = DBIx::Recordset \-> Select (\e%params, \f(CB$fields\fB, \f(CB$order\fB)\fR" 4 .IX Item "*set = DBIx::Recordset -> Select (%params, $fields, $order)" .PD 0 .IP "\fB\f(CB$set\fB \-> Select (\e%params, \f(CB$fields\fB, \f(CB$order\fB)\fR" 4 .IX Item "$set -> Select (%params, $fields, $order)" .IP "\fB\f(CB$set\fB \-> Select ($where, \f(CB$fields\fB, \f(CB$order\fB)\fR" 4 .IX Item "$set -> Select ($where, $fields, $order)" .PD Selects records from the recordsets table(s). .Sp The first syntax setups a new DBIx::Recordset object and does the select. .Sp The second and third syntax selects from an existing DBIx::Recordset object. .Sp \&\fBparams:\fR setup (only syntax 1), where (without \f(CW$order\fR and \f(CW$fields\fR) .Sp \&\fBwhere:\fR (only syntax 3) string for \s-1SQL WHERE\s0 expression .Sp \&\fBfields:\fR comma separated list of fieldnames to select .Sp \&\fBorder:\fR comma separated list of fieldnames to sort on .IP "\fB*set = DBIx::Recordset \-> Search (\e%params)\fR" 4 .IX Item "*set = DBIx::Recordset -> Search (%params)" .PD 0 .IP "\fBset \-> Search (\e%params)\fR" 4 .IX Item "set -> Search (%params)" .PD Does a search on the given tables and prepares data to access them via \&\f(CW@set\fR or \f(CW%set\fR. The first syntax also sets up a new object. .Sp \&\fBparams:\fR setup (only syntax 1), where, search .IP "\fB*set = DBIx::Recordset \-> Insert (\e%params)\fR" 4 .IX Item "*set = DBIx::Recordset -> Insert (%params)" .PD 0 .IP "\fB\f(CB$set\fB \-> Insert (\e%params)\fR" 4 .IX Item "$set -> Insert (%params)" .PD Inserts a new record in the recordset table(s). Params should contain one entry for every field for which you want to insert a value. .Sp Fieldnames may be prefixed with a '\e' in which case they are not processed (quoted) in any way. .Sp \&\fBparams:\fR setup (only syntax 1), fields .IP "\fB*set = DBIx::Recordset \-> Update (\e%params, \f(CB$where\fB)\fR" 4 .IX Item "*set = DBIx::Recordset -> Update (%params, $where)" .PD 0 .IP "\fB*set = DBIx::Recordset \-> Update (\e%params, \f(CB$where\fB)\fR" 4 .IX Item "*set = DBIx::Recordset -> Update (%params, $where)" .IP "\fBset \-> Update (\e%params, \f(CB$where\fB)\fR" 4 .IX Item "set -> Update (%params, $where)" .IP "\fBset \-> Update (\e%params, \f(CB$where\fB)\fR" 4 .IX Item "set -> Update (%params, $where)" .PD Updates one or more records in the recordset table(s). Parameters should contain one entry for every field you want to update. The \f(CW$where\fR contains the \s-1SQL WHERE\s0 condition as a string or as a reference to a hash. If \f(CW$where\fR is omitted, the where conditions are buily from the parameters. If !PrimKey is given for the table, only that !PrimKey is used for the \s-1WHERE\s0 clause. .Sp Fieldnames may be prefixed with a '\e', in which case they are not processed (quoted) in any way. .Sp \&\fBparams:\fR setup (only syntax 1+2), where (only if \f(CW$where\fR is omitted), fields .IP "\fB*set = DBIx::Recordset \-> Delete (\e%params)\fR" 4 .IX Item "*set = DBIx::Recordset -> Delete (%params)" .PD 0 .IP "\fB\f(CB$set\fB \-> Delete (\e%params)\fR" 4 .IX Item "$set -> Delete (%params)" .PD Deletes one or more records from the recordsets table(s). .Sp \&\fBparams:\fR setup (only syntax 1), where .IP "\fB*set = DBIx::Recordset \-> DeleteWithLinks (\e%params)\fR" 4 .IX Item "*set = DBIx::Recordset -> DeleteWithLinks (%params)" .PD 0 .IP "\fB\f(CB$set\fB \-> DeleteWithLinks (\e%params)\fR" 4 .IX Item "$set -> DeleteWithLinks (%params)" .PD Deletes one or more records from the recordsets table(s). Additonal all record of links with have the \f(CW\*(C`!OnDelete\*(C'\fR set, are either deleted or the correspending field is set to undef. What to do is determinated by the constants \f(CW\*(C`odDELETE\*(C'\fR and \f(CW\*(C`odCLEAR\*(C'\fR. This is very helpful to guaratee the inetgrity of the database. .Sp \&\fBparams:\fR setup (only syntax 1), where .IP "\fB*set = DBIx::Recordset \-> Execute (\e%params)\fR" 4 .IX Item "*set = DBIx::Recordset -> Execute (%params)" .PD 0 .IP "\fB\f(CB$set\fB \-> Execute (\e%params)\fR" 4 .IX Item "$set -> Execute (%params)" .PD Executes one of the above methods, depending on the given arguments. If multiple execute parameters are specified, the priority is =search =update =insert =delete =empty .Sp If none of the above parameters are specified, a search is performed. A search is always performed. On an \f(CW\*(C`=update\*(C'\fR, the \f(CW\*(C`!PrimKey\*(C'\fR, if given, is looked upon and used for the where part of the \s-1SQL\s0 statement, while all other parameters are updated. .Sp \&\fBparams:\fR setup (only syntax 1), execute, where, search, fields .IP "\fB\f(CB$set\fB \-> do ($statement, \f(CB$attribs\fB, \e%params)\fR" 4 .IX Item "$set -> do ($statement, $attribs, %params)" Same as \s-1DBI.\s0 Executes a single \s-1SQL\s0 statement on the open database. .IP "\fB\f(CB$set\fB \-> Reset ()\fR" 4 .IX Item "$set -> Reset ()" Set the record pointer to the initial state, so the next call to .Sp \&\f(CW\*(C`Next\*(C'\fR returns the first row. .IP "\fB\f(CB$set\fB \-> First ()\fR" 4 .IX Item "$set -> First ()" Position the record pointer to the first row and returns it. .IP "\fB\f(CB$set\fB \-> Next ()\fR" 4 .IX Item "$set -> Next ()" Position the record pointer to the next row and returns it. .IP "\fB\f(CB$set\fB \-> Prev ()\fR" 4 .IX Item "$set -> Prev ()" Position the record pointer to the previous row and returns it. .IP "\fB\f(CB$set\fB \-> Curr ()\fR" 4 .IX Item "$set -> Curr ()" Returns the current row. .IP "\fB\f(CB$set\fB \-> AllNames ()\fR" 4 .IX Item "$set -> AllNames ()" Returns a reference to an array of all fieldnames of all tables used by the object. .IP "\fB\f(CB$set\fB \-> Names ()\fR" 4 .IX Item "$set -> Names ()" Returns a reference to an array of the fieldnames from the last query. .IP "\fB\f(CB$set\fB \-> AllTypes ()\fR" 4 .IX Item "$set -> AllTypes ()" Returns a reference to an array of all fieldtypes of all tables used by the object. .IP "\fB\f(CB$set\fB \-> Types ()\fR" 4 .IX Item "$set -> Types ()" Returns a reference to an array of the fieldtypes from the last query. .IP "\fB\f(CB$set\fB \-> Add ()\fR" 4 .IX Item "$set -> Add ()" .PD 0 .IP "\fB\f(CB$set\fB \-> Add (\e%data)\fR" 4 .IX Item "$set -> Add (%data)" .PD Adds a new row to a recordset. The first one adds an empty row, the second one will assign initial data to it. The Add method returns an index into the array where the new record is located. .Sp .Vb 1 \& Example: \& \& # Add an empty record \& $i = $set \-> Add () ; \& # Now assign some data \& $set[$i]{id} = 5 ; \& $set[$i]{name} = \*(Aqtest\*(Aq ; \& # and here it is written to the database \& # (without Flush it is written, when the record goes out of scope) \& $set \-> Flush () ; .Ve .Sp Add will also set the current record to the newly created empty record. So, you can assign the data by simply using the current record. .Sp .Vb 5 \& # Add an empty record \& $set \-> Add () ; \& # Now assign some data to the new record \& $set{id} = 5 ; \& $set{name} = \*(Aqtest\*(Aq ; .Ve .IP "\fB\f(CB$set\fB \-> MoreRecords ([$ignoremax])\fR" 4 .IX Item "$set -> MoreRecords ([$ignoremax])" Returns true if there are more records to fetch from the current recordset. If the \f(CW$ignoremax\fR parameter is specified and is true, MoreRecords ignores the \f(CW$max\fR parameter of the last Search. .Sp To tell you if there are more records, More actually fetches the next record from the database and stores it in memory. It does not, however, change the current record. .IP "\fB\f(CB$set\fB \-> PrevNextForm ($prevtext, \f(CB$nexttext\fB, \e%fdat)\fR" 4 .IX Item "$set -> PrevNextForm ($prevtext, $nexttext, %fdat)" .PD 0 .IP "\fB\f(CB$set\fB \-> PrevNextForm (\e%param, \e%fdat)\fR" 4 .IX Item "$set -> PrevNextForm (%param, %fdat)" .PD Returns a \s-1HTML\s0 form which contains a previous and a next button and all data from \f(CW%fdat\fR, as hidden fields. When calling the Search method, You must set the \f(CW$max\fR parameter to the number of rows you want to see at once. After the search and the retrieval of the rows, you can call PrevNextForm to generate the needed buttons for scrolling through the recordset. .Sp The second for allows you the specifies addtional parameter, which creates first, previous, next, last and goto buttons. Example: .Sp .Vb 3 \& $set \-> PrevNextForm ({\-first => \*(AqFirst\*(Aq, \-prev => \*(Aq< \*(AqNext>>\*(Aq, \-last => \*(AqLast\*(Aq, \& \-goto => \*(AqGoto #\*(Aq}, \e%fdat) .Ve .Sp The goto button lets you jump to an random record number. If you obmit any of the parameters, the corresponding button will not be shown. .IP "\fB\f(CB$set\fB \-> Flush\fR" 4 .IX Item "$set -> Flush" The Flush method flushes all data to the database and therefore makes sure that the db is up-to-date. Normally, DBIx::Recordset holds the update in memory until the row is destroyed, by either a new Select/Search or by the Recordsetobject itself is destroyed. With this method you can make sure that every update is really written to the db. .IP "\fB\f(CB$set\fB \-> Dirty ()\fR" 4 .IX Item "$set -> Dirty ()" Returns true if there is at least one dirty row containing unflushed data. .IP "\fBDBIx::Recordset::Undef ($name)\fR" 4 .IX Item "DBIx::Recordset::Undef ($name)" Undef takes the name of a typglob and will destroy the array, the hash, and the object. All unwritten data is written to the db. All db connections are closed and all memory is freed. .Sp .Vb 3 \& Example: \& # this destroys $set, @set and %set \& DBIx::Recordset::Undef (\*(Aqset\*(Aq) ; .Ve .IP "\fB\f(CB$set\fB \-> Begin\fR" 4 .IX Item "$set -> Begin" Starts a transaction. Calls the \s-1DBI\s0 method begin. .IP "\fB\f(CB$set\fB \-> Rollback\fR" 4 .IX Item "$set -> Rollback" Rolls back a transaction. Calls the \s-1DBI\s0 method rollback and makes sure that all internal buffers of DBIx::Recordset are flushed. .IP "\fB\f(CB$set\fB \-> Commit\fR" 4 .IX Item "$set -> Commit" Commits a transaction. Calls the \s-1DBI\s0 method commit and makes sure that all internal buffers of DBIx::Recordset are flushed. .IP "\fB\f(CB$set\fB \-> DBHdl ()\fR" 4 .IX Item "$set -> DBHdl ()" Returns the \s-1DBI\s0 database handle. .IP "\fB\f(CB$set\fB \-> StHdl ()\fR" 4 .IX Item "$set -> StHdl ()" Returns the \s-1DBI\s0 statement handle of the last select. .IP "\fB\f(CB$set\fB \-> TableName ()\fR" 4 .IX Item "$set -> TableName ()" Returns the name of the table of the recordset object. .IP "\fB\f(CB$set\fB \-> TableNameWithOutFilter ()\fR" 4 .IX Item "$set -> TableNameWithOutFilter ()" Returns the name of the table of the recordset object, but removes the string given with !TableFilter, if it is the prefix of the table name. .IP "\fB\f(CB$set\fB \-> PrimKey ()\fR" 4 .IX Item "$set -> PrimKey ()" Returns the primary key given in the !PrimKey parameter. .IP "\fB\f(CB$set\fB \-> TableFilter ()\fR" 4 .IX Item "$set -> TableFilter ()" Returns the table filter given in the !TableFilter parameter. .IP "\fB\f(CB$set\fB \-> StartRecordNo ()\fR" 4 .IX Item "$set -> StartRecordNo ()" Returns the record number of the record which will be returned for index 0. .IP "\fB\f(CB$set\fB \-> LastSQLStatement ()\fR" 4 .IX Item "$set -> LastSQLStatement ()" Returns the last executed \s-1SQL\s0 Statement. .IP "\fB\f(CB$set\fB \-> LastSerial ()\fR" 4 .IX Item "$set -> LastSerial ()" Return the last value of the field defined with !Serial .IP "\fB\f(CB$set\fB \-> Disconnect ()\fR" 4 .IX Item "$set -> Disconnect ()" Closes the connection to the database. .IP "\fB\f(CB$set\fB \-> Link($linkname)\fR" 4 .IX Item "$set -> Link($linkname)" If \f(CW$linkname\fR is undef, returns reference to a hash of all links of the object. Otherwise, it returns a reference to the link with the given name. .IP "\fB\f(CB$set\fB \-> \fBLinks()\fB\fR" 4 .IX Item "$set -> Links()" Returns reference to a hash of all links of the object. .IP "\fB\f(CB$set\fB \-> Link4Field($fieldname)\fR" 4 .IX Item "$set -> Link4Field($fieldname)" Returns the name of the link for that field, or if there is no link for that field. .IP "\fB\f(CB$set\fB \-> TableAttr ($key, \f(CB$value\fB, \f(CB$table\fB)\fR" 4 .IX Item "$set -> TableAttr ($key, $value, $table)" get and/or set an attribute of the table .RS 4 .ie n .IP "$key" 4 .el .IP "\f(CW$key\fR" 4 .IX Item "$key" key to set/get .ie n .IP "$value" 4 .el .IP "\f(CW$value\fR" 4 .IX Item "$value" if present, set key to this value .ie n .IP "$table" 4 .el .IP "\f(CW$table\fR" 4 .IX Item "$table" Optional, let you specify another table, then the one use by the recordset object. .RE .RS 4 .RE .IP "\fB\f(CB$set\fB \-> Stats ()\fR" 4 .IX Item "$set -> Stats ()" Returns an hash ref with some statistical values. .IP "\fB\f(CB$set\fB \-> LastError ()\fR" 4 .IX Item "$set -> LastError ()" .PD 0 .IP "\fBDBIx::Recordset \-> LastError ()\fR" 4 .IX Item "DBIx::Recordset -> LastError ()" .PD Returns the last error message, if any. If called in an array context the first element receives the last error message and the second the last error code. .SH "DATA ACCESS" .IX Header "DATA ACCESS" The data which is returned by a \fBSelect\fR or a \fBSearch\fR can be accessed in two ways: .PP 1.) Through an array. Each item of the array corresponds to one of the selected records. Each array-item is a reference to a hash containing an entry for every field. .PP Example: \f(CW$set\fR[1]{id} access the field 'id' of the second record found \f(CW$set\fR[3]{name} access the field 'name' of the fourth record found .PP The record is fetched from the \s-1DBD\s0 driver when you access it the first time and is stored by DBIx::Recordset for later access. If you don't access the records one after each other, the skipped records are not stored and therefore can't be accessed anymore, unless you specify the \fB!StoreAll\fR parameter. .PP 2.) DBIx::Recordset holds a \fBcurrent record\fR which can be accessed directly via a hash. The current record is the one you last accessed via the array. After a Select or Search, it is reset to the first record. You can change the current record via the methods \fBNext\fR, \fBPrev\fR, \fBFirst\fR, \fBAdd\fR. .PP Example: \f(CW$set\fR{id} access the field 'id' of the current record \f(CW$set\fR{name} access the field 'name' of the current record .PP Instead of doing a \fBSelect\fR or \fBSearch\fR you can directly access one row of a table when you have tied a hash to DBIx::Recordset::Hash or have specified the \fB!HashAsRowKey\fR Parameter. The hashkey will work as primary key to the table. You must specify the \&\fB!PrimKey\fR as setup parameter. .PP Example: \f(CW$set\fR{4}{name} access the field 'name' of the row with primary key = 4 .SH "MODIFYING DATA DIRECTLY" .IX Header "MODIFYING DATA DIRECTLY" One way to update/insert data into the database is by using the Update, Insert or Execute method of the DBIx::Recordset object. A second way is to directly assign new values to the result of a previous Select/Search. .PP Example: # setup a new object and search all records with name xyz *set = DBIx::Recordset \-> Search ({'!DataSource' => 'dbi:db:tab', '!PrimKey => 'id', '!Table' => 'tabname', 'name' => 'xyz'}) ; .PP .Vb 3 \& #now you can update an existing record by assigning new values \& #Note: if possible, specify a PrimKey for update to work faster \& $set[0]{\*(Aqname\*(Aq} = \*(Aqzyx\*(Aq ; \& \& # or insert a new record by setting up an new array row \& $set[9]{\*(Aqname\*(Aq} = \*(Aqfoo\*(Aq ; \& $set[9]{\*(Aqid\*(Aq} = 10 ; \& \& # if you don\*(Aqt know the index of a new row you can obtain \& # one by using Add \& my $i = $set \-> Add () ; \& $set[$i]{\*(Aqname\*(Aq} = \*(Aqmore foo\*(Aq ; \& $set[$i]{\*(Aqid\*(Aq} = 11 ; \& \& # or add an empty record via Add and assign the values to the current \& # record \& $set \-> Add () ; \& $set{\*(Aqname\*(Aq} = \*(Aqmore foo\*(Aq ; \& $set{\*(Aqid\*(Aq} = 11 ; \& \& # or insert the data directly via Add \& $set \-> Add ({\*(Aqname\*(Aq => \*(Aqeven more foo\*(Aq, \& \*(Aqid\*(Aq => 12}) ; \& \& # NOTE: up to this point, NO data is actually written to the db! \& \& # we are done with that object, Undef will flush all data to the db \& DBIx::Recordset::Undef (\*(Aqset\*(Aq) ; .Ve .PP \&\s-1IMPORTANT:\s0 The data is not written to the database until you explicitly call \fBflush\fR, or a new query is started, or the object is destroyed. This is to keep the actual writes to the database to a minimum. .SH "WORKING WITH MULTIPLE TABLES" .IX Header "WORKING WITH MULTIPLE TABLES" DBIx::Recordset has some nice features to make working with multiple tables and their relations easier. .SS "Joins" .IX Subsection "Joins" First, you can specify more than one table to the \fB!Table\fR parameter. If you do so, you need to specify how both tables are related. You do this with \fB!TabRelation\fR parameter. This method will access all the specified tables simultanously. .SS "Join Example:" .IX Subsection "Join Example:" If you have the following two tables, where the field street_id is a pointer to the table street: .PP .Vb 3 \& table name \& name char (30), \& street_id integer \& \& table street \& id integer, \& street char (30), \& city char (30) .Ve .PP You can perform the following search: .PP .Vb 3 \& *set = DBIx::Recordset \-> Search ({\*(Aq!DataSource\*(Aq => \*(Aqdbi:drv:db\*(Aq, \& \*(Aq!Table\*(Aq => \*(Aqname, street\*(Aq, \& \*(Aq!TabRelation\*(Aq=> \*(Aqname.street_id = street.id\*(Aq}) ; .Ve .PP The result is that you get a set which contains the fields \fBname\fR, \fBstreet_id\fR, \&\fBstreet\fR, \fBcity\fR and \fBid\fR, where id is always equal to street_id. If there are multiple streets for one name, you will get as many records for that name as there are streets present for it. For this reason, this approach works best when you have a 1:1 relation. .PP It is also possible to specify \fBJOINs\fR. Here's how: .PP .Vb 4 \& *set = DBIx::Recordset \-> Search ({ \& \*(Aq!DataSource\*(Aq => \*(Aqdbi:drv:db\*(Aq, \& \*(Aq!Table\*(Aq => \*(Aqname, street\*(Aq, \& \*(Aq!TabJoin\*(Aq => \*(Aqname LEFT JOIN street ON (name.street_id=street.id)\*(Aq}) ; .Ve .PP The difference between this and the first example is that this version also returns a record even if neither table contains a record for the given id. The way it's done depends on the \s-1JOIN\s0 you are given (\s-1LEFT/RIGHT/INNER\s0) (see your \s-1SQL\s0 documentation for details about JOINs). .SS "Links" .IX Subsection "Links" If you have 1:n relations between two tables, the following may be a better way to handle it: .PP .Vb 10 \& *set = DBIx::Recordset \-> Search ({\*(Aq!DataSource\*(Aq => \*(Aqdbi:drv:db\*(Aq, \& \*(Aq!Table\*(Aq => \*(Aqname\*(Aq, \& \*(Aq!Links\*(Aq => { \& \*(Aq\-street\*(Aq => { \& \*(Aq!Table\*(Aq => \*(Aqstreet\*(Aq, \& \*(Aq!LinkedField\*(Aq => \*(Aqid\*(Aq, \& \*(Aq!MainField\*(Aq => \*(Aqstreet_id\*(Aq \& } \& } \& }) ; .Ve .PP After that query, every record will contain the fields \fBname\fR and \fBstreet_id\fR. Additionally, there is a pseudofield named \fB\-street\fR, which could be used to access another recordset object, which is the result of a query where \fBstreet_id = id\fR. Use .PP .Vb 4 \& $set{name} to access the name field \& $set{\-street}{street} to access the first street (as long as the \& current record of the subobject isn\*(Aqt \& modified) \& \& $set{\-street}[0]{street} first street \& $set{\-street}[1]{street} second street \& $set{\-street}[2]{street} third street \& \& $set[2]{\-street}[1]{street} to access the second street of the \& third name .Ve .PP You can have multiple linked tables in one recordset; you can also nest linked tables or link a table to itself. .PP \&\fB\s-1NOTE:\s0\fR If you select only some fields and not all, the field which is specified by \&'!MainField' must be also given in the '!Fields' or '$fields' parameter. .PP \&\fB\s-1NOTE:\s0\fR See also \fBAutomatic detection of links\fR below .SS "LinkName" .IX Subsection "LinkName" In the LinkName feature you may specify a \*(L"name\*(R" for every table. A name is one or more fields which gives a human readable \*(L"key\*(R" of that record. For example in the above example \&\fBid\fR is the key of the record, but the human readable form is \fBstreet\fR. .PP .Vb 12 \& *set = DBIx::Recordset \-> Search ({\*(Aq!DataSource\*(Aq => \*(Aqdbi:drv:db\*(Aq, \& \*(Aq!Table\*(Aq => \*(Aqname\*(Aq, \& \*(Aq!LinkName\*(Aq => 1, \& \*(Aq!Links\*(Aq => { \& \*(Aq\-street\*(Aq => { \& \*(Aq!Table\*(Aq => \*(Aqstreet\*(Aq, \& \*(Aq!LinkedField\*(Aq => \*(Aqid\*(Aq, \& \*(Aq!MainField\*(Aq => \*(Aqstreet_id\*(Aq, \& \*(Aq!NameField\*(Aq => \*(Aqstreet\*(Aq \& } \& } \& }) ; .Ve .PP For every record in the table, this example will return the fields: .PP .Vb 1 \& name street_id street .Ve .PP If you have more complex records, you may also specify more than one field in !NameField and pass it as an reference to an array e.g. ['street', 'city']. In this case, the result will contain .PP .Vb 1 \& name street_id street city .Ve .PP If you set !LinkName to 2, the result will contain the fields .PP .Vb 1 \& name street_id STREET_ID .Ve .PP where \s-1STREET_ID\s0 contains the values of the street and city fields joined together. If you set !LinkName to 3, you will get only .PP .Vb 1 \& name street_id .Ve .PP where street_id contains the values of the street and city fields joined together. .PP \&\s-1NOTE:\s0 The !NameField can also be specified as a table attribute with the function TableAttr. In this case you don't need to specify it in every link. When a !NameField is given in a link description, it overrides the table attribute. .SS "Automatic detection of links" .IX Subsection "Automatic detection of links" DBIx::Recordset and DBIx::Database will try to automatically detect links between tables based on the field and table names. For this feature to work, the field which points to another table must consist of the table name and the field name of the destination joined together with an underscore (as in the above example name.street_id). Then it will automatically recognized as a pointer to street.id. .PP .Vb 2 \& *set = DBIx::Recordset \-> Search ({\*(Aq!DataSource\*(Aq => \*(Aqdbi:drv:db\*(Aq, \& \*(Aq!Table\*(Aq => \*(Aqname\*(Aq) ; .Ve .PP is enough. DBIx::Recordset will automatically add the !Links attribute. Additionally, DBIx::Recordset adds a backlink (which starts with a star ('*')), so for the table street, in our above example, there will be a link, named *name, which is a pointer from table street to all records in the table name where street.id is equal to name.street_id. .PP You may use the !Links attribute to specify links which can not be automatically detected. .PP \&\s-1NOTE:\s0 To specify more then one link from one table to another table, you may prefix the field name with an specifier followed by two underscores. Example: first_\|_street_id, second_\|_street_id. The link (and backlink) names are named with the prefix, e.g. \-first_\|_street and the backlink *first_\|_name. .SH "DBIx::Database" .IX Header "DBIx::Database" The DBIx::Database object gathers information about a datasource. Its main purpose is to create, at startup, an object which retrieves all necessary information from the database. This object detects links between tables and stores this information for use by the DBIx::Recordset objects. There are additional methods which allow you to add kinds of information which cannot be retrieved automatically. .PP Example: .PP .Vb 4 \& $db = DBIx::Database \-> new ({\*(Aq!DataSource\*(Aq => $DSN, \& \*(Aq!Username\*(Aq => $User, \& \*(Aq!Password\*(Aq => $Password, \& \*(Aq!KeepOpen\*(Aq => 1}) ; \& \& *set = DBIx::Recordset \-> Search ({\*(Aq!DataSource\*(Aq => $db, \& \*(Aq!Table\*(Aq => \*(Aqfoo\*(Aq, \& }) ; .Ve .ie n .SS "new ($data_source, $username, $password, \e%attr, $saveas, $keepopen)" .el .SS "new ($data_source, \f(CW$username\fP, \f(CW$password\fP, \e%attr, \f(CW$saveas\fP, \f(CW$keepopen\fP)" .IX Subsection "new ($data_source, $username, $password, %attr, $saveas, $keepopen)" .ie n .IP "$data_source" 4 .el .IP "\f(CW$data_source\fR" 4 .IX Item "$data_source" Specifies the database to which to connect. Driver/DB/Host. Same as the first parameter to the \s-1DBI\s0 connect function. .ie n .IP "$username" 4 .el .IP "\f(CW$username\fR" 4 .IX Item "$username" Username (optional) .ie n .IP "$password" 4 .el .IP "\f(CW$password\fR" 4 .IX Item "$password" Password (optional) .IP "\e%attr" 4 .IX Item "%attr" Attributes (optional) Same as the attribute parameter to the \s-1DBI\s0 connect function. .ie n .IP "$saveas" 4 .el .IP "\f(CW$saveas\fR" 4 .IX Item "$saveas" Name for this DBIx::Database object to save as. The name can be used in DBIx::Database::Get, or as !DataSource parameter in call to the DBIx::Recordset object. .Sp This is intended as mechanism to retrieve the necessary metadata; for example, when your web server starts (e.g. in the startup.pl file of mod_perl). Here you can give the database object a name. Later in your mod_perl or Embperl scripts, you can use this metadata by specifying this name. This will speed up the setup of DBIx::Recordset object without the need to pass a reference to the DBIx::Database object. .ie n .IP "$keepopen" 4 .el .IP "\f(CW$keepopen\fR" 4 .IX Item "$keepopen" Normaly the database connection will be closed after the metadata has been retrieved from the database. This makes sure you don't get trouble when using the new method in a mod_perl startup file. You can keep the connection open to use them in further setup calls to DBIx::Recordset objects. When the database is not kept open, you must specify the \f(CW\*(C`!Password\*(C'\fR parameter each time the recordset has to be reopend. .ie n .IP "$tabfilter" 4 .el .IP "\f(CW$tabfilter\fR" 4 .IX Item "$tabfilter" same as setup parameter !TableFilter .ie n .IP "$doonconnect" 4 .el .IP "\f(CW$doonconnect\fR" 4 .IX Item "$doonconnect" same as setup parameter !DoOnConnect .ie n .IP "$reconnect" 4 .el .IP "\f(CW$reconnect\fR" 4 .IX Item "$reconnect" If set, forces \fIDBIx::Database\fR to \f(CW\*(C`undef\*(C'\fR any preexisting database handle and call connect in any case. This is useful in together with \fIApache::DBI\fR. While the database connection are still kept open by \fIApache::DBI\fR, \fIApache::DBI\fR preforms a test if the handle is still vaild (which DBIx::Database itself wouldn't). .PP You also can specify a hashref which can contain the following parameters: .PP !DataSource, !Username, !Password, !DBIAttr, !SaveAs, !KeepOpen, !TableFilter, !DoOnConnect, !Reconnect .ie n .SS "$db = DBIx::Database \-> DBHdl" .el .SS "\f(CW$db\fP = DBIx::Database \-> DBHdl" .IX Subsection "$db = DBIx::Database -> DBHdl" returns the database handle (only if you specify !KeepOpen when calling \f(CW\*(C`new\*(C'\fR). .ie n .SS "$db = DBIx::Database \-> Get ($name)" .el .SS "\f(CW$db\fP = DBIx::Database \-> Get ($name)" .IX Subsection "$db = DBIx::Database -> Get ($name)" \&\f(CW$name\fR = The name of the DBIx::Database object you wish to retrieve .PP Get a DBIx::Database object which has already been set up based on the name. .ie n .SS "$db \-> TableAttr ($table, $key, $value)" .el .SS "\f(CW$db\fP \-> TableAttr ($table, \f(CW$key\fP, \f(CW$value\fP)" .IX Subsection "$db -> TableAttr ($table, $key, $value)" get and/or set an attribute for an specfic table. .ie n .IP "$table" 4 .el .IP "\f(CW$table\fR" 4 .IX Item "$table" Name of table(s). You may use '*' instead of the table name to specify a default value which applies to all tables for which no other value is specified. .ie n .IP "$key" 4 .el .IP "\f(CW$key\fR" 4 .IX Item "$key" key to set/get .ie n .IP "$value" 4 .el .IP "\f(CW$value\fR" 4 .IX Item "$value" if present, set key to this value .ie n .SS "$db \-> TableLink ($table, $linkname, $value)" .el .SS "\f(CW$db\fP \-> TableLink ($table, \f(CW$linkname\fP, \f(CW$value\fP)" .IX Subsection "$db -> TableLink ($table, $linkname, $value)" Get and/or set a link description for an table. If no \f(CW$linkname\fR is given, returns all links for that table. .ie n .IP "$table" 4 .el .IP "\f(CW$table\fR" 4 .IX Item "$table" Name of table(s) .ie n .IP "$linkname" 4 .el .IP "\f(CW$linkname\fR" 4 .IX Item "$linkname" Name of link to set/get .ie n .IP "$value" 4 .el .IP "\f(CW$value\fR" 4 .IX Item "$value" if present, this must be a reference to a hash with the link decription. See !Links for more information. .ie n .SS "$db \-> MetaData ($table, $metadata, $clear)" .el .SS "\f(CW$db\fP \-> MetaData ($table, \f(CW$metadata\fP, \f(CW$clear\fP)" .IX Subsection "$db -> MetaData ($table, $metadata, $clear)" Get and/or set the meta data for the given table. .ie n .IP "$table" 4 .el .IP "\f(CW$table\fR" 4 .IX Item "$table" Name of table(s) .ie n .IP "$metadata" 4 .el .IP "\f(CW$metadata\fR" 4 .IX Item "$metadata" If present, this must be a reference to a hash with the new metadata. You should only use this if you really know what you are doing. .ie n .IP "$clear" 4 .el .IP "\f(CW$clear\fR" 4 .IX Item "$clear" Clears the metadata for the given table, The next call to DBIx::Database \-> new will recreate the metadata. Useful if your table has changed (e.g. by \&\s-1ALTER TABLE\s0). .ie n .SS "$db \-> AllTables" .el .SS "\f(CW$db\fP \-> AllTables" .IX Subsection "$db -> AllTables" This returns a reference to a hash of the keys to all the tables of the datasource. .ie n .SS "$db \-> AllNames ($table)" .el .SS "\f(CW$db\fP \-> AllNames ($table)" .IX Subsection "$db -> AllNames ($table)" Returns a reference to an array of all fieldnames for the given table. .ie n .SS "$db \-> AllTypes ($table)" .el .SS "\f(CW$db\fP \-> AllTypes ($table)" .IX Subsection "$db -> AllTypes ($table)" Returns a reference to an array of all fieldtypes for the given table. .ie n .IP "$db \-> do ($statement, $attribs, \e%params)" 4 .el .IP "\f(CW$db\fR \-> do ($statement, \f(CW$attribs\fR, \e%params)" 4 .IX Item "$db -> do ($statement, $attribs, %params)" Same as \s-1DBI.\s0 Executes a single \s-1SQL\s0 statement on the open database. .ie n .SS "$db \-> CreateTables ($dbschema, $schemaname, $user, $setpriv, $alterconstraints)" .el .SS "\f(CW$db\fP \-> CreateTables ($dbschema, \f(CW$schemaname\fP, \f(CW$user\fP, \f(CW$setpriv\fP, \f(CW$alterconstraints\fP)" .IX Subsection "$db -> CreateTables ($dbschema, $schemaname, $user, $setpriv, $alterconstraints)" The CreateTables method is used to create an modify the schema of your database. The idea is to define the schema as a Perl data structure and give it to this function, it will compare the actual schema of the database with the one provided and creates new tables, new fields or drop fields as necessary. It also sets the permission on the tables and is able to create indices for the tables. It will \fBnever\fR drop a whole table! \&\s-1NOTE:\s0 Create tables cannot deteminate changes of the datatype of a fields, because \s-1DBI\s0 is not able to provide this information in a standard way. .ie n .IP "$dbschema" 4 .el .IP "\f(CW$dbschema\fR" 4 .IX Item "$dbschema" Either the name of a file which contains the schema or a array ref. See below how this schema must look like. .ie n .IP "$schemaname" 4 .el .IP "\f(CW$schemaname\fR" 4 .IX Item "$schemaname" schemaname (only used for Oracle) .ie n .IP "$user" 4 .el .IP "\f(CW$user\fR" 4 .IX Item "$user" User that should be granted access. See \f(CW\*(C`!Grant\*(C'\fR parameter. .ie n .IP "$setpriv" 4 .el .IP "\f(CW$setpriv\fR" 4 .IX Item "$setpriv" If set to true, access privilegs are revoked and granted again for already existing tables. That is necessary when \f(CW$user\fR changes. .ie n .IP "$alterconstraints" 4 .el .IP "\f(CW$alterconstraints\fR" 4 .IX Item "$alterconstraints" If set to true contrains are cleared/set for already existing fields. \s-1DBI\s0 doesn't provide a database independ way to check which contrains already exists. .SS "Schema definition" .IX Subsection "Schema definition" If give as a filename, the file must contain an hash \f(CW%DBDefault\fR and an array \f(CW@DBSchema\fR. The first gives default and the second is an array of hashs. Every of this hash defines one table. .PP Example: .PP .Vb 1 \& %DBDefault = \& \& ( \& \*(Aq!Grant\*(Aq => \& [ \& \*(Aqselect\*(Aq, \& \*(Aqinsert\*(Aq, \& \*(Aqupdate\*(Aq, \& \*(Aqdelete\*(Aq, \& ], \& ) \& ; \& \& \& @DBSchema = ( \& \& { \& \*(Aq!Table\*(Aq => \*(Aqlanguage\*(Aq, \& \*(Aq!Fields\*(Aq => \& [ \& \*(Aqid\*(Aq => \*(Aqchar (2)\*(Aq, \& \*(Aqdirectory\*(Aq => \*(Aqvarchar(40)\*(Aq, \& \*(Aqname\*(Aq => \*(Aqvarchar(40)\*(Aq, \& \*(Aqeurope\*(Aq => \*(Aqbool\*(Aq, \& ], \& \*(Aq!PrimKey\*(Aq => \*(Aqid\*(Aq, \& \*(Aq!Default\*(Aq => \& { \& \*(Aqeurope\*(Aq => 1, \& }, \& \*(Aq!Init\*(Aq => \& [ \& {\*(Aqid\*(Aq => \*(Aqde\*(Aq, \*(Aqdirectory\*(Aq => \*(Aqhtml_49\*(Aq, \*(Aqname\*(Aq => \*(Aqdeutsch\*(Aq}, \& {\*(Aqid\*(Aq => \*(Aqen\*(Aq, \*(Aqdirectory\*(Aq => \*(Aqhtml_76\*(Aq, \*(Aqname\*(Aq => \*(Aqenglish\*(Aq}, \& {\*(Aqid\*(Aq => \*(Aqfr\*(Aq, \*(Aqdirectory\*(Aq => \*(Aqhtml_31\*(Aq, \*(Aqname\*(Aq => \*(Aqfrench\*(Aq}, \& ], \& \*(Aq!Index\*(Aq => \& [ \& \*(Aqdirectory\*(Aq => \*(Aq\*(Aq, \& ] \& \& }, \& \& ); .Ve .PP The hash which defines a table can have the following keys: .IP "!Table" 4 .IX Item "!Table" Gives the table name .IP "!Fields" 4 .IX Item "!Fields" Array with field names and types. There a some types which a translated database specifc. You can define more database specific translation in Compat.pm. .RS 4 .IP "bit" 4 .IX Item "bit" boolean .IP "counter" 4 .IX Item "counter" If an autoincrementing integer. For databases (like Oracle) that doesn't have such a datatype a sequence is generated to provide the autoincrement value and the fields will be of type integer. .IP "tinytext" 4 .IX Item "tinytext" variables length text with up to 255 characters .IP "text" 4 .IX Item "text" variables length text .RE .RS 4 .RE .IP "!PrimKey" 4 .IX Item "!PrimKey" Name of the primary key .IP "!For" 4 .IX Item "!For" Can contain the same key as the table definintion, but is only executed for a specifc database. .Sp Example: .Sp .Vb 5 \& \*(Aq!For\*(Aq => { \& \*(AqOracle\*(Aq => { \& \*(Aq!Constraints\*(Aq => \& { \& \*(Aqweb_id\*(Aq => [\*(Aqforeign key\*(Aq => \*(AqREFERENCES web (id)\*(Aq], \& \& \*(Aqprim_\|_menu_id\*(Aq => [\*(Aq!Name\*(Aq => \*(Aqweb_prim_menu_id\*(Aq, \& \*(Aqforeign key\*(Aq => \*(AqREFERENCES menu (id)\*(Aq, \& \*(Aqnot null\*(Aq => \*(Aq\*(Aq], \& } \& }, \& }, .Ve .IP "!Contraints" 4 .IX Item "!Contraints" Used to define constraints. See example under \f(CW\*(C`!For\*(C'\fR. .RS 4 .IP "!Name => " 4 .IX Item "!Name => " .PD 0 .IP " => " 4 .IX Item " => " .RE .RS 4 .RE .IP "!Init" 4 .IX Item "!Init" .PD Used to initialy populate the table. .IP "!Default" 4 .IX Item "!Default" Used to set a default value for a field, when the table is created. This doesn't have any affect for further INSERTs/UPDATEs. .IP "!Grant" 4 .IX Item "!Grant" Give the rights that should be grant to \f(CW$user\fR .IP "!Index" 4 .IX Item "!Index" Gives the names for the fields for which indices should be created. If the second parameter for an index is not empty, it gives the index name, otherwise a default name is used. .ie n .SS "$db \-> DropTables ($schemaname, $user)" .el .SS "\f(CW$db\fP \-> DropTables ($schemaname, \f(CW$user\fP)" .IX Subsection "$db -> DropTables ($schemaname, $user)" Drops \fBall\fR tables. Use with care! .ie n .IP "$schemaname" 4 .el .IP "\f(CW$schemaname\fR" 4 .IX Item "$schemaname" schemaname (only used for Oracle) .ie n .IP "$user" 4 .el .IP "\f(CW$user\fR" 4 .IX Item "$user" User that should be revoked access. See \f(CW\*(C`!Grant\*(C'\fR parameter. .SH "Casesensitive/insensitiv" .IX Header "Casesensitive/insensitiv" In \s-1SQL\s0 all names (field/tablenames etc.) should be case insensitive. Various \&\s-1DBMS\s0 handle the case of names differently. For that reason \fIDBIx::Recordset\fR translates all names to lower case, ensuring your application will run with any \s-1DBMS,\s0 regardless of whether names are returned in lower/uppercase by the \&\s-1DBMS.\s0 Some \s-1DBMS\s0 are case-sensitive (I know at least Sybase, depending on your collate settings). To use such a case-sensitive \s-1DBMS,\s0 it is best to create your database with all names written in lowercase. In a situation where this isn't possible, you can set \f(CW$PreserveCase\fR to 1. In this case DBIx::Recordset will not perform any case translation. \fB\s-1NOTE:\s0\fR \f(CW$PreserveCase\fR is still experimental and may change in future releases. .ie n .SH "FETCHSIZE / $FetchsizeWarn" .el .SH "FETCHSIZE / \f(CW$FetchsizeWarn\fP" .IX Header "FETCHSIZE / $FetchsizeWarn" Some operations in Perl (i.e. \f(CW\*(C`foreach\*(C'\fR, assigning arrays) need to know the size of the whole array. When Perl needs to know the size of an array it call the method \&\f(CW\*(C`FETCHSIZE\*(C'\fR. Since not all \s-1DBD\s0 drivers/DBMS returns the number of selected rows after an \s-1SQL\s0 \f(CW\*(C`SELECT\*(C'\fR, the only way to really determine the number of selected rows would be to fetch them all from the \s-1DBMS.\s0 Since this could cause a lot of work, it may be very inefficent. Therefore \fIDBIx::Recordset\fR by default calls \fBdie()\fR when Perl calls \&\s-1FETCHSIZE.\s0 If you know your \s-1DBD\s0 drivers returns the correct value in \f(CW$sth\fR \-> \f(CW\*(C`rows\*(C'\fR after the execution of an \f(CW\*(C`SELECT\*(C'\fR, you can set \f(CW$FetchsizeWarn\fR to zero to let \&\f(CW\*(C`FETCHSIZE\*(C'\fR return the value from \f(CW$sth\fR \-> \f(CW\*(C`rows\*(C'\fR. Setting it to 1 will cause \&\fIDBIx::Recordset\fR to only issue a warning, but perform the operation. .PP \&\fB\s-1NOTE:\s0\fR Since I don't have enough experience with the behaviour of this feature with different \s-1DBMS,\s0 this is considered experimental. .SH "DEBUGGING" .IX Header "DEBUGGING" DBIx::Recordset is able to write a logfile so you can see what's happening inside. There are two public variables and the \f(CW\*(C`!Debug\*(C'\fR parameter used for this purpose: .ie n .IP "$DBIx::Recordset::Debug or !Debug" 4 .el .IP "\f(CW$DBIx::Recordset::Debug\fR or !Debug" 4 .IX Item "$DBIx::Recordset::Debug or !Debug" Debuglevel 0 = off 1 = log only errors 2 = show connect, disconnect and \s-1SQL\s0 Statements 3 = some more infos 4 = much infos .Sp \&\f(CW$DBIx::Recordset::Debug\fR sets the default debug level for new objects, \&\f(CW\*(C`!Debug\*(C'\fR can be used to set the debuglevel on a per object basis. .IP "DBIx::Recordset::LOG" 4 .IX Item "DBIx::Recordset::LOG" The filehandle used for logging. The default is \s-1STDOUT,\s0 unless you are running under HTML::Embperl, in which case the default is the Embperl logfile. .PP .Vb 1 \& Example: \& \& # open the log file \& open LOG, ">test.log" or die "Cannot open test.log" ; \& \& # assign filehandle \& *DBIx::Recordset::LOG = \e*LOG ; \& \& # set debugging level \& $DBIx::Recordset::Debug = 2 ; \& \& # now you can create a new DBIx::Recordset object .Ve .SH "SECURITY" .IX Header "SECURITY" Since one possible application of DBIx::Recordset is its use in a web-server environment, some attention should paid to security issues. .PP The current version of DBIx::Recordset does not include extended security management, but some features can be used to make your database access safer. (More security features will come in future releases.) .PP First of all, use the security feature of your database. Assign the web server process as few rights as possible. .PP The greatest security risk is when you feed DBIx::Recordset a hash which contains the formfield data posted to the web server. Somebody who knows DBIx::Recordset can post other parameters than those you would expect a normal user to post. For this reason, a primary issue is to override all parameters which should \fBnever\fR be posted by your script. .PP Example: *set = DBIx::Recordset \-> Search ({%fdat, ('!DataSource' => \&\*(L"dbi:$Driver:$DB\*(R", '!Table' => \*(L"$Table\*(R")}) ; .PP (assuming your posted form data is in \f(CW%fdat\fR). The above call will make sure that nobody from outside can override the values supplied by \f(CW$Driver\fR, \f(CW$DB\fR and \&\f(CW$Table\fR. .PP It is also wise to initialize your objects by supplying parameters which can not be changed. .PP Somewhere in your script startup (or at server startup time) add a setup call: .PP .Vb 3 \& *set = DBIx::Recordset\-> Setup ({\*(Aq!DataSource\*(Aq => "dbi:$Driver:$DB", \& \*(Aq!Table\*(Aq => "$Table", \& \*(Aq!Fields\*(Aq => "a, b, c"}) ; .Ve .PP Later, when you process a request you can write: .PP .Vb 1 \& $set \-> Search (\e%fdat) ; .Ve .PP This will make sure that only the database specified by \f(CW$Driver\fR, \f(CW$DB\fR, the table specified by \f(CW$Table\fR and the Fields a, b, and c can be accessed. .SH "Compatibility with different DBD drivers" .IX Header "Compatibility with different DBD drivers" I have put a great deal of effort into making DBIx::Recordset run with various \s-1DBD\s0 drivers. The problem is that not all necessary information is specified via the \s-1DBI\s0 interface (yet). So I have made the module \fBDBIx::Compat\fR which gives information about the difference between various \s-1DBD\s0 drivers and their underlying database systems. Currently, there are definitions for: .IP "\fBDBD::mSQL\fR" 4 .IX Item "DBD::mSQL" .PD 0 .IP "\fBDBD::mysql\fR" 4 .IX Item "DBD::mysql" .IP "\fBDBD::Pg\fR" 4 .IX Item "DBD::Pg" .IP "\fBDBD::Solid\fR" 4 .IX Item "DBD::Solid" .IP "\fB\s-1DBD::ODBC\s0\fR" 4 .IX Item "DBD::ODBC" .IP "\fB\s-1DBD::CSV\s0\fR" 4 .IX Item "DBD::CSV" .IP "\fBDBD::Oracle (requires DBD::Oracle 0.60 or higher)\fR" 4 .IX Item "DBD::Oracle (requires DBD::Oracle 0.60 or higher)" .IP "\fBDBD::Sysbase\fR" 4 .IX Item "DBD::Sysbase" .IP "\fBDBD::Informix\fR" 4 .IX Item "DBD::Informix" .IP "\fBDBD::InterBase\fR" 4 .IX Item "DBD::InterBase" .PD .PP DBIx::Recordset has been tested with all those \s-1DBD\s0 drivers (on Linux 2.0.32, except \&\s-1DBD::ODBC,\s0 which has been tested on Windows '95 using Access 7 and with \s-1MS SQL\s0 Server). .PP If you want to use another \s-1DBD\s0 driver with DBIx::Recordset, it may be necessary to create an entry for that driver. See \fBperldoc DBIx::Compat\fR for more information. .SH "EXAMPLES" .IX Header "EXAMPLES" The following are some examples of how to use DBIx::Recordset. The Examples are from the test.pl. The examples show the DBIx::Recordset call first, followed by the generated \s-1SQL\s0 command. .PP .Vb 2 \& *set = DBIx::Recordset\-> Setup ({\*(Aq!DataSource\*(Aq => "dbi:$Driver:$DB", \& \*(Aq!Table\*(Aq => "$Table"}) ; .Ve .PP Setup a DBIx::Recordset for driver \f(CW$Driver\fR, database \f(CW$DB\fR to access table \f(CW$Table\fR. .PP .Vb 1 \& $set \-> Select () ; \& \& SELECT * from ; \& \& \& $set \-> Select ({\*(Aqid\*(Aq=>2}) ; \& is the same as \& $set1 \-> Select (\*(Aqid=2\*(Aq) ; \& \& SELECT * from
WHERE id = 2 ; \& \& \& $set \-> Search({ \*(Aq$fields\*(Aq => \*(Aqid, balance AS paid \- total \*(Aq }) ; \& \& SELECT id, balance AS paid \- total FROM
\& \& \& $set \-> Select ({name => "Second Name\etFirst Name"}) ; \& \& SELECT * from
WHERE name = \*(AqSecond Name\*(Aq or name = \*(AqFirst Name\*(Aq ; \& \& \& $set1 \-> Select ({value => "9991 9992\et9993", \& \*(Aq$valuesplit\*(Aq => \*(Aq |\et\*(Aq}) ; \& \& SELECT * from
WHERE value = 9991 or value = 9992 or value = 9993 ; \& \& \& $set \-> Select ({\*(Aq+name&value\*(Aq => "9992"}) ; \& \& SELECT * from
WHERE name = \*(Aq9992\*(Aq or value = 9992 ; \& \& \& $set \-> Select ({\*(Aq+name&value\*(Aq => "Second Name\et9991"}) ; \& \& SELECT * from
WHERE (name = \*(AqSecond Name\*(Aq or name = \*(Aq9991) or \& (value = 0 or value = 9991) ; \& \& \& $set \-> Search ({id => 1,name => \*(AqFirst Name\*(Aq,addon => \*(AqIs\*(Aq}) ; \& \& SELECT * from
WHERE id = 1 and name = \*(AqFirst Name\*(Aq and addon = \*(AqIs\*(Aq ; \& \& \& $set1 \-> Search ({\*(Aq$start\*(Aq=>0,\*(Aq$max\*(Aq=>2, \*(Aq$order\*(Aq=>\*(Aqid\*(Aq}) or die "not ok \&($DBI::errstr)" ; \& \& SELECT * from
ORDER BY id ; \& B Because of the B and B only records 0,1 will be returned \& \& \& $set1 \-> Search ({\*(Aq$start\*(Aq=>0,\*(Aq$max\*(Aq=>2, \*(Aq$next\*(Aq=>1, \*(Aq$order\*(Aq=>\*(Aqid\*(Aq}) or die "not ok \&($DBI::errstr)" ; \& \& SELECT * from
ORDER BY id ; \& B Because of the B, B and B only records 2,3 will be \&returned \& \& \& $set1 \-> Search ({\*(Aq$start\*(Aq=>2,\*(Aq$max\*(Aq=>1, \*(Aq$prev\*(Aq=>1, \*(Aq$order\*(Aq=>\*(Aqid\*(Aq}) or die "not ok \&($DBI::errstr)" ; \& \& SELECT * from
ORDER BY id ; \& B Because of the B, B and B only records 0,1,2 will be \&returned \& \& \& $set1 \-> Search ({\*(Aq$start\*(Aq=>5,\*(Aq$max\*(Aq=>5, \*(Aq$next\*(Aq=>1, \*(Aq$order\*(Aq=>\*(Aqid\*(Aq}) or die "not ok \&($DBI::errstr)" ; \& \& SELECT * from
ORDER BY id ; \& B Because of the B, B and B only records 5\-9 will be \&returned \& \& \& *set6 = DBIx::Recordset \-> Search ({ \*(Aq!DataSource\*(Aq => "dbi:$Driver:$DB", \& \*(Aq!Table\*(Aq => "t1, t2", \& \*(Aq!TabRelation\*(Aq => \& "t1.value=t2.value", \& \*(Aq!Fields\*(Aq => \*(Aqid, name, text\*(Aq, \& \*(Aqid\*(Aq => "2\et4" }) or die "not ok \&($DBI::errstr)" ; \& \& SELECT id, name, text FROM t1, t2 WHERE (id=2 or id=4) and t1.value=t2.value ; \& \& \& $set6 \-> Search ({\*(Aqname\*(Aq => "Fourth Name" }) or die "not ok \&($DBI::errstr)" ; \& SELECT id, name, text FROM t1, t2 WHERE (name = \*(AqFourth Name\*(Aq) and \&t1.value=t2.value \&; \& \& \& \& $set6 \-> Search ({\*(Aqid\*(Aq => 3, \& \*(Aq$operator\*(Aq => \*(Aq<\*(Aq }) or die "not ok ($DBI::errstr)" ; \& \& SELECT id, name, text FROM t1, t2 WHERE (id < 3) and t1.value=t2.value ; \& \& \& $set6 \-> Search ({\*(Aqid\*(Aq => 4, \& \*(Aqname\*(Aq => \*(AqSecond Name\*(Aq, \& \*(Aq*id\*(Aq => \*(Aq<\*(Aq, \& \*(Aq*name\*(Aq => \*(Aq<>\*(Aq }) or die "not ok ($DBI::errstr)" ; \& \& SELECT id, name, text FROM t1, t2 WHERE (id<4 and name <> \*(AqSecond Name\*(Aq) and \&t1.value=t2.value ; \& \& \& $set6 \-> Search ({\*(Aqid\*(Aq => 2, \& \*(Aqname\*(Aq => \*(AqFourth Name\*(Aq, \& \*(Aq*id\*(Aq => \*(Aq<\*(Aq, \& \*(Aq*name\*(Aq => \*(Aq=\*(Aq, \& \*(Aq$conj\*(Aq => \*(Aqor\*(Aq }) or die "not ok ($DBI::errstr)" ; \& \& SELECT id, name, text FROM t1, t2 WHERE (id<2 or name=\*(AqFourth Name\*(Aq) and \&t1.value=t2.value ; \& \& \& $set6 \-> Search ({\*(Aq+id|addon\*(Aq => "7\etit", \& \*(Aqname\*(Aq => \*(AqFourth Name\*(Aq, \& \*(Aq*id\*(Aq => \*(Aq<\*(Aq, \& \*(Aq*addon\*(Aq => \*(Aq=\*(Aq, \& \*(Aq*name\*(Aq => \*(Aq<>\*(Aq, \& \*(Aq$conj\*(Aq => \*(Aqand\*(Aq }) or die "not ok ($DBI::errstr)" ; \& \& SELECT id, name, text FROM t1, t2 WHERE (t1.value=t2.value) and ( ((name <> \&Fourth \&Name)) and ( ( id < 7 or addon = 7) or ( id < 0 or addon = 0))) \& \& \& $set6 \-> Search ({\*(Aq+id|addon\*(Aq => "6\etit", \& \*(Aqname\*(Aq => \*(AqFourth Name\*(Aq, \& \*(Aq*id\*(Aq => \*(Aq>\*(Aq, \& \*(Aq*addon\*(Aq => \*(Aq<>\*(Aq, \& \*(Aq*name\*(Aq => \*(Aq=\*(Aq, \& \*(Aq$compconj\*(Aq => \*(Aqand\*(Aq, \& \*(Aq$conj\*(Aq => \*(Aqor\*(Aq }) or die "not ok ($DBI::errstr)" ; \& \& \& SELECT id, name, text FROM t1, t2 WHERE (t1.value=t2.value) and ( ((name = \&Fourth \&Name)) or ( ( id > 6 and addon <> 6) or ( id > 0 and addon <> 0))) ; \& \& \& *set7 = DBIx::Recordset \-> Search ({ \*(Aq!DataSource\*(Aq => "dbi:$Driver:$DB", \& \*(Aq!Table\*(Aq => "t1, t2", \& \*(Aq!TabRelation\*(Aq => "t1.id=t2.id", \& \*(Aq!Fields\*(Aq => \*(Aqname, typ\*(Aq}) or die "not ok \&($DBI::errstr)" ; \& \& SELECT name, typ FROM t1, t2 WHERE t1.id=t2.id ; \& \& \& %h = (\*(Aqid\*(Aq => 22, \& \*(Aqname2\*(Aq => \*(Aqsqlinsert id 22\*(Aq, \& \*(Aqvalue2\*(Aq=> 1022) ; \& \& \& *set9 = DBIx::Recordset \-> Insert ({%h, \& (\*(Aq!DataSource\*(Aq => "dbi:$Driver:$DB", \& \*(Aq!Table\*(Aq => "$Table[1]")}) or die "not ok \&($DBI::errstr)" ; \& \& INSERT INTO
(id, name2, value2) VALUES (22, \*(Aqsqlinsert id 22\*(Aq, 1022) ; \& \& \& %h = (\*(Aqid\*(Aq => 22, \& \*(Aqname2\*(Aq => \*(Aqsqlinsert id 22u\*(Aq, \& \*(Aqvalue2\*(Aq=> 2022) ; \& \& \& $set9 \-> Update (\e%h, \*(Aqid=22\*(Aq) or die "not ok ($DBI::errstr)" ; \& \& UPDATE
WHERE id=22 SET id=22, name2=\*(Aqsqlinsert id 22u\*(Aq, value2=2022 ; \& \& \& %h = (\*(Aqid\*(Aq => 21, \& \*(Aqname2\*(Aq => \*(Aqsqlinsert id 21u\*(Aq, \& \*(Aqvalue2\*(Aq=> 2021) ; \& \& *set10 = DBIx::Recordset \-> Update ({%h, \& (\*(Aq!DataSource\*(Aq => "dbi:$Driver:$DB", \& \*(Aq!Table\*(Aq => "$Table[1]", \& \*(Aq!PrimKey\*(Aq => \*(Aqid\*(Aq)}) or die "not ok \&($DBI::errstr)" ; \& \& UPDATE
WHERE id=21 SET name2=\*(Aqsqlinsert id 21u\*(Aq, value2=2021 ; \& \& \& %h = (\*(Aqid\*(Aq => 21, \& \*(Aqname2\*(Aq => \*(AqReady for delete 21u\*(Aq, \& \*(Aqvalue2\*(Aq=> 202331) ; \& \& \& *set11 = DBIx::Recordset \-> Delete ({%h, \& (\*(Aq!DataSource\*(Aq => "dbi:$Driver:$DB", \& \*(Aq!Table\*(Aq => "$Table[1]", \& \*(Aq!PrimKey\*(Aq => \*(Aqid\*(Aq)}) or die "not ok \&($DBI::errstr)" ; \& \& DELETE FROM
WHERE id = 21 ; \& \& \& \& *set12 = DBIx::Recordset \-> Execute ({\*(Aqid\*(Aq => 20, \& \*(Aq*id\*(Aq => \*(Aq<\*(Aq, \& \*(Aq!DataSource\*(Aq => "dbi:$Driver:$DB", \& \*(Aq!Table\*(Aq => "$Table[1]", \& \*(Aq!PrimKey\*(Aq => \*(Aqid\*(Aq}) or die "not ok \&($DBI::errstr)" ; \& \& SELECT * FROM
WHERE id<20 ; \& \& \& *set13 = DBIx::Recordset \-> Execute ({\*(Aq=search\*(Aq => \*(Aqok\*(Aq, \& \*(Aqname\*(Aq => \*(AqFourth Name\*(Aq, \& \*(Aq!DataSource\*(Aq => "dbi:$Driver:$DB", \& \*(Aq!Table\*(Aq => "$Table[0]", \& \*(Aq!PrimKey\*(Aq => \*(Aqid\*(Aq}) or die "not ok ($DBI::errstr)" ; \& \& SELECT * FROM
WHERE ((name = Fourth Name)) \& \& \& $set12 \-> Execute ({\*(Aq=insert\*(Aq => \*(Aqok\*(Aq, \& \*(Aqid\*(Aq => 31, \& \*(Aqname2\*(Aq => \*(Aqinsert by exec\*(Aq, \& \*(Aqvalue2\*(Aq => 3031, \& # Execute should ignore the following params, since it is already setup \& \*(Aq!DataSource\*(Aq => "dbi:$Driver:$DB", \& \*(Aq!Table\*(Aq => "quztr", \& \*(Aq!PrimKey\*(Aq => \*(Aqid99\*(Aq}) or die "not ok ($DBI::errstr)" ; \& \& SELECT * FROM
; \& \& \& $set12 \-> Execute ({\*(Aq=update\*(Aq => \*(Aqok\*(Aq, \& \*(Aqid\*(Aq => 31, \& \*(Aqname2\*(Aq => \*(Aqupdate by exec\*(Aq}) or die "not ok ($DBI::errstr)" ; \& \& UPDATE
SET name2=update by exec,id=31 WHERE id=31 ; \& \& \& $set12 \-> Execute ({\*(Aq=insert\*(Aq => \*(Aqok\*(Aq, \& \*(Aqid\*(Aq => 32, \& \*(Aqname2\*(Aq => \*(Aqinsert/upd by exec\*(Aq, \& \*(Aqvalue2\*(Aq => 3032}) or die "not ok ($DBI::errstr)" ; \& \& \& INSERT INTO
(name2,id,value2) VALUES (insert/upd by exec,32,3032) ; \& \& \& $set12 \-> Execute ({\*(Aq=delete\*(Aq => \*(Aqok\*(Aq, \& \*(Aqid\*(Aq => 32, \& \*(Aqname2\*(Aq => \*(Aqins/update by exec\*(Aq, \& \*(Aqvalue2\*(Aq => 3032}) or die "not ok ($DBI::errstr)" ; \& \& DELETE FROM
WHERE id=32 ; .Ve .SH "SUPPORT" .IX Header "SUPPORT" As far as possible for me, support will be available via the \s-1DBI\s0 Users' mailing list. (dbi\-user@fugue.com) .SH "AUTHOR" .IX Header "AUTHOR" G.Richter (richter@dev.ecos.de) .SH "SEE ALSO" .IX Header "SEE ALSO" .IP "\fBPerl\fR\|(1)" 4 .IX Item "Perl" .PD 0 .IP "\s-1\fBDBI\s0\fR\|(3)" 4 .IX Item "DBI" .IP "\fBDBIx::Compat\fR\|(3)" 4 .IX Item "DBIx::Compat" .IP "\fBHTML::Embperl\fR\|(3) http://perl.apache.org/embperl/" 4 .IX Item "HTML::Embperl http://perl.apache.org/embperl/" .IP "\fBTie::DBI\fR\|(3) http://stein.cshl.org/~lstein/Tie\-DBI/" 4 .IX Item "Tie::DBI http://stein.cshl.org/~lstein/Tie-DBI/"