Alan Pesola wrote:
> How can I get the data type of each column(text, single,date etc...)
> Not familiar with hashes!!
Get familiar with them...
> This command $sth->{TYPE}; will supposedly return an array reference
> for each column but how do I read it correctly?? I keep getting
> Array(hexvalue)
That indicates a reference -- get familiar with them, too.
Use an extra level of indirection to get the result you really want.
> use DBI;
> my $dsn = "somedsn";
> my $dbh = DBI->connect("dbi:ODBC:$dsn") || print "$DBI::errstr\n";
> my $sql = "SELECT somecols FROM sometable";
> my $sth = $dbh->prepare($sql) || print "$DBI::errstr\n";
>
> $sth->execute;
> my $num_cols = $sth->{NUM_OF_FIELDS};
> print "Getting $num_cols columns<br>";
> while(@results = $sth->fetchrow_array) {
> print "@results<br>\n";
> }
> $dbh->disconnect;
$sth->{TYPE}[0] returns the first type:
perl -MDBI -w <<'!'
$dbh=DBI->connect('dbi:Informix:stores','','',{RaiseError=>1});
$sth=$dbh->prepare("select * from customer");
print "$sth->{TYPE}[0]\n";
print "$sth->{ix_NativeTypeName}[0]\n";
!
This prints 4 (meaning INTEGER, I hope), and SERIAL (the real type as
far as I'm concerned).
--
Yours,
Jonathan Leffler ([EMAIL PROTECTED]) #include <disclaimer.h>
Guardian of DBD::Informix v1.00.PC1 -- http://www.perl.com/CPAN
"I don't suffer from insanity; I enjoy every minute of it!"