The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Genezzo::Havok::SQLScalar - scalar SQL functions

SYNOPSIS

HavokUse("Genezzo::Havok::SQLScalar")

DESCRIPTION

ARGUMENTS

FUNCTIONS

perl functions

See perlfunc(1) for descriptions.

chomp
chop
chr
crypt
index
lc
lcfirst
length
ord
pack
reverse
rindex
sprintf
substr
uc
ucfirst
abs
atan2
cos
exp
hex
int
oct
rand
sin
sqrt
srand
perl_join

The perl string join, renamed to avoid conflict with the SQL relational join

SQL string functions

concat(char1, char2)

Concatenate strings

greatest(item1, item2...)

Find the greatest element in a list

initcap(char)

Return the string with the initial letter of each word capitalized, where words are defined as contiguous groups of alphanumeric chars separated by non-word chars.

least(item1, item2...)

Find the smallest element in a list

lower(char)

Return the string with all letters lowercase

lpad(char1, n [, char2])

Returns the string char1 padded out on the left to length n with copies of char2. If char2 is not specified blanks are used. If char1 is larger than length n it is truncated to fit.

ltrim(char [, set])

Returns the string which is trimmed on the left up to the first character which is not in the specified set. If set is unspecified, blanks are trimmed.

soundex

Knuth's soundex from Text::Soundex.

replace(char, search_str [, replace_str])

Returns char with all occurrences of the search_str replaced by replace_str. If the replace_str is unspecified or null, it removes all occurrences of the search_str.

rpad(char1, n [, char2])

Returns the string char1 padded out on the right to length n with copies of char2. If char2 is not specified blanks are used. If char1 is larger than length n it is truncated to fit.

rtrim(char [, set])

Returns the string which is trimmed on the rightt up to the first character which is not in the specified set. If set is unspecified, blanks are trimmed.

translate(char, search_str, replace_str)

Similar to perl transliteration tr/ (see perlop(1) ), returns a string where all occurrences of a character in the search string are replaced with the corresponding character in the replace string.

upper(char)

Returns the string with all characters uppercase.

SQL math functions

cosh(n)

Hyperbolic cosine

ceil(n)

Returns the smallest integer greater than or equal to n

floor

Returns the largest integers less than or equal to n

ln

Natural log.

log10

Log base 10.

logN(base_N, num)

Returns the Log base base_N on num.

mod(m,n)

Returns the remainder of m divided by n.

power(m,n)

Returns m**n

round(num [, m])

Return num rounded to m places to the right of the decimal point. M=0 if not specified. If m is negative num is rounded to the left of the decimal point.

sign(n)

Similar to "spaceship", returns -1 for N < 0, 0 for N==0, and 1 for N > 0.

sinh

Hyperbolic sine.

tan

tangent

tanh

Hyperbolic tangent.

trunc(num [, m])

Return num truncated to m places to the right of the decimal point. M=0 if not specified. If m is negative num is truncated to the left of the decimal point.

SQL conversion functions

These functions return a value of a different type than their operands.

ascii(char)

Return the ascii value of the first char of the string.

instr(char, substring [, position [, occurrence]])

Returns the index (1 based, not zero based) of the substring in the char, starting at position. If occurrence and position are not specified they default to one: instr returns the index of the first occurrence of the substring. If occurrence is specified instr returns the index of the Nth occurrence. If position is negative instr begins the search from the tail end of char.

nvl(char1, char2)

Returns char2 if char1 is NULL, else returns char1

Genezzo functions

quurl

"Quote URL" - Replace all non-alphanumeric chars in a string with '%hex' values, similar to the standard URL-style quoting.

quurl2

"Quote URL" - Replace most non-alphanumeric chars in a string with '%hex' values, leaving spaces and most punctuation (with the exception of '%') untouched.

unquurl

Convert a "quoted url" string back.

EXPORT

LIMITATIONS

In Perl, "log" is a natural log, but the standard SQL log function is log base N. To prevent confusion in usage, Genezzo supplies a natural log function "ln", a base 10 function "log10", and a log of variable base called "logN".

The current implementation does not do any compile-time type checking of arguments for any functions.

AUTHOR

Jeffrey I. Cohen, jcohen@genezzo.com

SEE ALSO

perl(1).

Copyright (c) 2005, 2006 Jeffrey I Cohen. All rights reserved.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

Address bug reports and comments to: jcohen@genezzo.com

For more information, please visit the Genezzo homepage at http://www.genezzo.com