DBIx::IO::GenLib - General helper functions and constants for database apps.
use DBIx::IO::GenLib; use DBIx::IO::GenLib (); # Don't import default symbols use DBIx::IO::GenLib qw(:tag symbol...) # Import selected symbols
$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);
$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
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.
$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.
@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.
$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.
$bool = isreal($scalar);
Return true if $scalar is a real number.
$bool = isint($scalar);
Return true if $scalar is an integer (signed or unsigned).
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"
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 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
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'
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.
These tags can be used to import the corresponding symbols:
$UPDATE_ACTION $READ_ACTION $INSERT_ACTION $DELETE_ACTION