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

NAME

Velocis::SQL - Perl interface to the Raima Velocis SQL database engine

SYNOPSIS

 use Velocis::SQL;

 $conn = db_connect($database,$user,$password)
   or die "could not connect -- ($Velocis::errorstate) $Velocis::errorstr";

 $query = $conn->execute($sql_statement)
   or die "Error -- ($Velocis::errorstate) $Velocis::errorstr";

 @array = $query->fetchrow();

 $val = $query->numrows();
 $val = $query->numcolumns();
 $val = $query->columntype($column_index);
 $val = $query->columnname($column_index);
 $val = $query->columnlength($column_index);

DESCRIPTION

This package is designed as close as possible to its C API counterpart. The C Programmer Guide that comes with Velocis describes most things you need.

Once you db_connect() to a database, you can then issue commands to the execute() method. If either of them returns an error from the underlying API, the value returned will be undef and the variable $Velocis::errorstr will contain the error message from the database, and the variable $Velocis::errorstate will contain the Velocis error state.

The function fetchrow() returns an array of the values from the next row fetched from the server. It returns an empty list when there is no more data available. Calling fetchrow() on a statement handle which is not from a SELECT statement has undefined behavior. Other functions work identically to their similarly-named C API functions.

To import all the SQL type definitions for use with columntype(), use:

    use Velocis::SQL qw(:DEFAULT :SQLTYPES);

No disconnect or free statements

Whenever the scalar that holds the statement or connection handle loses its value, the underlying data structures will be freed and appropriate connections closed. This can be accomplished by performing one of these actions:

undef the handle
use the handle for another purpose
let the handle run out of scope
exit the program.

Error messages

A global variable $Velocis::errorstr always holds the last error message. It is never reset except on the next error. The only time it holds a valid message is after execute() or db_connect() returns undef. If fetchrow() encountered an error from the database, it will set the error string to indicate the error and return an empty array; however, it will not clear the error string upon successful return, so you must first set it to the empty string if you wish to check it later (when fetchrow() returns an empty array).

PREREQUISITES

You need to have the Velocis database server installed and configured on your system to use this module.

Be sure to set the proper DEFINES in the Makefile.PL file for your architecture.

AUTHOR

Vivek Khera (vivek@khera.org). Many ideas were taken from the MsqlPerl module.