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(char_str)

Return the string with the trailing newline removed.

chop(char_str)

Return the string with the last character removed.

chr(number)

Returns the character represented by the number in the character set.

crypt(plaintext, salt)

Returns the plaintext string encrypted with the C crypt routine.

index(char_str, substr[, start_position])

Returns the position (0-based) of the first character of the substring in the string, or -1 if not found, starting at start_position. Start_position defaults to zero if not specified.

lc(char_str)

Returns the lowercased char_str.

lcfirst(char_str)

Returns char_str with only the first character lowercased.

length(char_str)

Returns the number of characters in char_str.

ord(char_str)

Returns the numeric encoding of the first character of char_str.

pack(template_str, list_of_values)

Converts a list of values into a string using the perl pack function.

reverse(char_str)

Returns the string in reverse order.

rindex(char_str, substr[, start_position])

Like index, but backwards: finds the last occurrence of the substr in char_str.

sprintf(format_str, list_of_values)

Returns a string formatted using the C sprintf.

Note that the sprintf format string must be single-quoted (SQL-style), not double-quoted.

substr(char_str, offset_position[, length])

Returns the substring of char_str, starting at the offset, of the specified length. If length is omitted the it returns from the offset to the end of the string. Special rules for negative offset, length.

uc(char_str)

Returns the uppercased char_str.

ucfirst(char_str)

Returns char_str with only the first character uppercased.

abs(number)

Absolute value

atan2(numberY, numberX)

Arctangent (in radians)

cos(number)

Cosine (in radians).

exp(n)

Returns e**n

hex(char_str)

Treats char_str as a hexadecimal value and converts to number.

int(number)

Returns the integer portion of number.

oct(char_str)

Treats char_str as a octal value and converts to number.

rand(number)

Returns returns a random number N, where 0 <= N < number. Note that N is not an integer, so use an expression like int(rand(Max_N)) to obtain integer values where 0 <= N <= (Max_N - 1).

sin(number)

Sine (in radians)

sqrt(number)

Square root.

srand(number)

Set the random seed.

perl_join(join_expr, char_str1, char_str2[, char_str3...])

The perl string join, renamed to avoid conflict with the SQL relational join. Concatenates the strings with the join_expr. Example: perl_join(':', 'foo', 'bar', 'baz') returns 'foo:bar:baz'.

SQL string functions

concat(char_str1, char_str2...)

Concatenate strings

greatest(item1, item2...)

Find the greatest element in a list

initcap(char_str)

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_str)

Return the string with all letters lowercase

lpad(char_str1, n [, char_str2])

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

ltrim(char_str [, 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(char_str)

Knuth's soundex from Text::Soundex.

replace(char_str, search_str [, replace_str])

Returns char_str 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(char_str1, n [, char_str2])

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

rtrim(char_str [, set])

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

translate(char_str, 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_str)

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(n)

Returns the largest integers less than or equal to n

ln(n)

Natural log.

log10(n)

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(n)

Hyperbolic sine.

tan(n)

tangent

tanh(n)

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_str)

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

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

Returns the index (1 based, not zero based) of the substring in the char_str, 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_str.

nvl(char_str1, char_str2)

Returns char_str2 if char_str1 is NULL, else returns char_str1

Genezzo functions

quurl(char_str)

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

quurl2(char_str)

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

unquurl(char_str)

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, 2007 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