DBD-DtfSQLmac

 view release on metacpan or  search on metacpan

lib/DBD/DtfSQLmac.pm  view on Meta::CPAN

sufficient if you either pass SQL_VARCHAR for string types or SQL_INTEGER for numeric types to bind_param (but you 
are not restricted to these two, see below). After the first call of bind_param, the type hint for that particular 
placeholder is "frozen", i.e. all subsequent calls to bind_param could be made without a type hint for that placeholder.
If the type hint is provided again, it will be ignored. In other words, you cannot change the type hint of a parameter
after the first call to bind_param (but it can be left unspecified, in which case it defaults to the previous value).
If your first call to bind_param for a particular placeholder has no type hint, SQL_VARCHAR is assumed as a default 
and cannot be changed afterwards. This may or may not be what you wanted, so be careful. Please note that the undef 
value, which indicates a NULL value, is compatible with every type. All undef values will be bound as the string NULL,
without quotation marks, even if the type is a string type (SQL_VARCHAR). 

Don't abuse placeholders for any element of a SQL statement that is not associated with a table's field, 
i.e. don't use a placeholder for a table name, column name, SQL-clause etc. A placeholder should always be treated 
as a column-parameter that has a column's data type (for which you then can provide the actual data). However, the 
DtfSQLmac driver doesn't prevent you from doing weird things with placeholders. But your code will probably fail with
other drivers, i.e. your code will not be portable.   


B<Data Types for Placeholders>

The TYPE value you provide to bind_param indicates a standard (non-driver-specific) type for this parameter. The 
DtfSQLmac driver supports the following ten DBI SQL type constants:

    SQL_TINYINT     (numeric) 
    SQL_SMALLINT    (numeric)  
    SQL_INTEGER     (numeric)  
    SQL_DOUBLE      (numeric)  
    SQL_DECIMAL     (numeric)  
    SQL_CHAR        (string type)
    SQL_VARCHAR     (string type)
    SQL_DATE        (string type) 
    SQL_TIME        (string type) 
    SQL_TIMESTAMP   (string type)

While the four following defined DBI SQL type numbers

    SQL_LONGVARCHAR -> SQL_VARCHAR
    SQL_NUMERIC     -> SQL_DECIMAL
    SQL_FLOAT       -> SQL_DOUBLE
    SQL_REAL        -> SQL_DOUBLE

will be mapped to their nearest corresponding DBI SQL type constant as shown, the three (as of DBI 1.08) binary 
data types (blob)

    SQL_BINARY
    SQL_VARBINARY
    SQL_LONGVARBINARY 
    
and 

    SQL_BIGINT (omitted/deprecated as of DBI 1.21)
	
are not supported at all. (Note that SQL_BIGINT was formerly mapped to SQL_INTEGER, but beginning with version
0.3201 of this module this mapping is no longer provided, since DBI 1.21 omitted SQL_BIGINT.) Likewise, B<any 
other> DBI SQL type constant found in more recent versions of the DBI module are not supported at all. You 
will get an error message if you specify one of these constants.

B<Please note:> With the DtfSQLmac driver, we always retrieve field values as string. This is done even for field values that have
a decimal (fixed point number) data type, although the underlying Mac::DtfSQL module allows the retrieval as decimal 
object for these fields (see the Mac::DtfSQL module documentation for details). Thus, all data you may retrieve from
the database is a scalar in Perl. These scalars will contain either numbers or strings. In general, conversion from 
one form to another is transparent, i.e. happens automatically in Perl. Generally, if a string represents a decimal, 
it is converted to a scalar holding a floating point number in arithmetical operations. Due to this conversion the 
accuracy may suffer. However, in order to avoid this, you are able to create a decimal object, assign it a value 
from a string that represents a decimal, perform arithmetical operations with it and then store it back to the 
database (see the C<dbi_6_update-decimal.pl> sample script).

See also the section on Placeholders and Bind Values in the DBI documentation for more information. 

=item B<bind_param_inout>   

Not supported.

=item B<execute,>

=item B<fetchrow_arrayref,> 

=item B<fetchrow_array,>    

=item B<fetchrow_hashref,>  

=item B<fetchall_arrayref,> 

=item B<finish> 

Work as expected.

=item B<rows>   

    $rv = $sth->rows;

Returns the number of rows affected by the last executed statement. 

Returns -1, if the statement is not a row affecting statement, for example a create, drop, grant, and revoke 
statement. If the statement was of a modifying kind (insert, update, delete statements), the number of affected 
records is returned. For select statements, the number of rows in the result set will be returned. You can always
rely on the returned row count information, as the dtF/SQL database engine is able to return valid values even 
for select statements.

=item B<bind_columns,>  

=item B<dump_results>   

Work as expected.

S< >

=back


=head2 Statement Handle Attributes

This section describes attributes specific to statement handles. Most of these attributes are read-only.

Example:

    ... = $sth->{NUM_OF_FIELDS};      # get/read

Note that the DtfSQLmac driver cannot provide valid values for most of the attributes until after 
$sth->execute has been called (except for the NUM_OF_PARAMS attribute, which is valid after $sth = $dbh->prepare). 




( run in 2.167 seconds using v1.01-cache-2.11-cpan-99c4e6809bf )