J. Michael Mahan > iodbc_ext_0_1 > iodbc

Download:
iodbc_ext_0_1.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.01   Source  

NAME ^

iodbc - Perl extension for the iODBC API

SYNOPSIS ^

This man page is not intended to be a manual on the ODBC API. Please see an ODBC manual for extended documentation on the usage of ODBC commands.

To use iodbc functions:

use iodbc;

DESCRIPTION ^

Everything in the extension follows the ODBC core API except that all function calls are pass by value. The one exception is SQLBindCol which needs to be passed a reference to a scalar. For More information please seek a ODBC manual and remember that this extension only works with core implementations.

Functions

The following functions are included with this iodbc extension. Parameters marked [i] are for input into the function while parameters marked [r] return data from a function.

EXAMPLES ^

use iodbc;

#

#To start I allocate handles and connect to my favorite data source. Notice I check every return code.

checkretcode(&SQLAllocEnv($henv));

checkretcode(SQLAllocConnect($henv, $hdbc));

checkretcode(SQLConnect($hdbc, "favorite_datsource", SQL_NTS, "user", SQL_NTS, "password", SQL_NTS));

checkretcode(SQLAllocStmt($hdbc,$hstmt));

#

#Then I execute a simple SQL statement

checkretcode(SQLExecDirect($hstmt, "SELECT * FROM sample_table", SQL_NTS));

#Bind column one to $rgbValue

checkretcode(SQLBindCol($hstmt, 1, SQL_C_DEFAULT, \$rgbValue, 24, SQL_NULL_DATA));

#Fetch all the rows and print them out

while(checkretcode(SQLFetch($hstmt))==SQL_SUCCESS){

print "$rgbValue\n";

}

#

#Finally close up shop by freeing statements and disconnecting.

checkretcode(SQLFreeStmt($hstmt, SQL_DROP));

checkretcode(SQLDisconnect($hdbc));

checkretcode(SQLFreeConnect($hdbc));

checkretcode(SQLFreeEnv($henv));

#

#This subroutine checks the return code to make sure that the function executed correctly

sub checkretcode {

my $retcode = shift;

if (($retcode==SQL_SUCCESS)||($retcode==SQL_NO_DATA_FOUND)) {

return $retcode;

} else {

die "some error";

}

}

TO DO ^

BUGS ^

Let me know if you find any.

AUTHOR ^

J. Michael Mahan, mahanm@nextwork.rose-hulman.edu

SEE ALSO ^

perl(1).

syntax highlighting: