NAME
DBIx::IO::GenLib - General helper functions and constants for database apps.
SYNOPSIS
use DBIx::IO::GenLib;
use DBIx::IO::GenLib (); # Don't import default symbols
use DBIx::IO::GenLib qw(:tag symbol...) # Import selected symbols
Functions
$normal_email = normalize_email($email_address);
@normal_dates = normalize_date(@dates_in_any_format);
$normal_date = normalize_date($date_in_any_format);
$normal_sysdate = local_normal_sysdate();
$bool = isreal($scalar);
$bool = isint($scalar);
Constants
$UPDATE_ACTION
$READ_ACTION
$INSERT_ACTION
$DELETE_ACTION
$LONG_READ_LENGTH
$UNKNOWN_DATE_FORMAT
$DATETIME_TYPE
$NUMERIC_TYPE
$CHAR_TYPE
$ROWID_TYPE
$LONG_TYPE
$LOB_TYPE
$BLOB_TYPE
$CLOB_TYPE
$DATE_TYPE
$TIME_TYPE
$YEAR_TYPE
$EMPTY_STRING
DESCRIPTION
This package contains miscellaneous functions for help in dealing with DBI and related DBIx::IO packages. See $NORMAL_DATETIME_FORMAT for a discussion of the canonical date format, functions are also provided to convert dates to this format.
DETAILS
Functions
normalize_email
-
$normal_email = normalize_email($email_address)
$email_address will be normalized using the following method. 1. Stripped of leading whitespace. 2. If whitespace still exists, $email_address will be truncated at that point. 3. Stripped of NUL characters "\0" 4. Converted to lower-case 5. Bounding < and > are removed 6. Any non-ascii characters at the end of the address are removed
This is useful in doing comparisons. No attempt is made to validate the address.
normalize_date
-
@normal_dates = normalize_date(@dates_in_any_format) $normal_date = normalize_date($date_in_any_format)
This function normalizes dates in almost any imaginable format (with the help of Date::Manip). Dates are returned in the normalized format (described elsewhere in this document). If the format of the input date isn't recognized (not likely) the corresponding output date is returned as undef.
CAUTION: The corresponding Date::Manip::UnixDate call is slow, if performance is a concern then prepare the date formats ahead of time and don't use this function. Because of Date::Manip's size, it will only be loaded via require if this particular function is used.
local_normal_sysdate
-
$normal_sysdate = local_normal_sysdate()
Return the current date and time in the normalized format (described elsewhere in this document) for use with easy date comparisons.
isreal
-
$bool = isreal($scalar);
Return true if $scalar is a real number.
isint
-
$bool = isint($scalar);
Return true if $scalar is an integer (signed or unsigned).
Constants
Set the maximum memory used to retrieve LONG or LOB datatypes.
$LONG_READ_LENGTH = 1000000
A string recognized by DBIx::IO::qualify() to convert the date format
$UNKNOWN_DATE_FORMAT = 'UNKNOWN'
A special string to be distinguished from the special NULL value of ''
$EMPTY_STRING = "\0\0\0\0"
- Action Constants
-
These are the allowed values for any function requiring an $action in DBIx::IO::Restrict and related modules:
$UPDATE_ACTION = "U" $READ_ACTION = "R" $INSERT_ACTION = "I" $DELETE_ACTION = "D"
- Data Types
-
Data types are represented by the following constants. These are useful in IO::qualify(). ##at these lists are incomplete
$DATETIME_TYPE $NUMERIC_TYPE $CHAR_TYPE $LONG_TYPE $LOB_TYPE
Oracle only: $BLOB_TYPE $CLOB_TYPE $ROWID_TYPE
NOTE: LOB types can be inserted/updated but not selected through DBD::Oracle (Version 1.19). If you need to retrieve such columns through DBI, I suggest converting the data type to LONG by rebuilding the table.
MySQL Only: $DATE_TYPE $TIME_TYPE $YEAR_TYPE
Driver Specific
The following are driver specific constants and can be loaded as
use DBIx::IO::XXXLib (...);
e.g.
use DBIx::IO::OracleLib ();
The format string, which gives the canonical date format used throughout this and related db packages (DBIx::IO) allows for date comparisons via numerical operators. This is also useful so that all date I/O is normalized in one format.
Oracle: $NORMAL_DATETIME_FORMAT = 'YYYYMMDDHH24MISS'
MySQL: $NORMAL_DATETIME_FORMAT = '%Y%m%d%H%i%S' $NORMAL_DATE_FORMAT = '%Y%m%d' $NORMAL_TIME_FORMAT = '%H%i%S'
Oracle pseudo columns. This is recognized as a column name that always has a datatype of $ROWID_TYPE: $ROWID_COL_NAME = 'ROWID'
SYMBOL IMPORTING
Default
These symbols are exported by default by this package:
normalize_email
normalize_date
local_normal_sysdate
isreal
inint
$LONG_READ_LENGTH
$UNKNOWN_DATE_FORMAT
$EMPTY_STRING
$DATETIME_TYPE
$NUMERIC_TYPE
$CHAR_TYPE
$ROWID_TYPE
$LONG_TYPE
$LOB_TYPE
$BLOB_TYPE
$CLOB_TYPE
$DATE_TYPE
$TIME_TYPE
$YEAR_TYPE
All symbols from driver-specific modules are exported by default.
Tags
These tags can be used to import the corresponding symbols:
actions
-
$UPDATE_ACTION $READ_ACTION $INSERT_ACTION $DELETE_ACTION
4 POD Errors
The following errors were encountered while parsing the POD:
- Around line 146:
You forgot a '=back' before '=head2'
- Around line 148:
'=item' outside of any '=over'
- Around line 269:
You forgot a '=back' before '=head2'
- Around line 283:
'=item' outside of any '=over'