----- Forwarded message from tanyi <[EMAIL PROTECTED]> -----
Delivered-To: [EMAIL PROTECTED]
Date: Tue, 24 Jun 2003 9:44:51 +0800
From: "tanyi" <[EMAIL PROTECTED]>
To: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
Subject:
????
????????????????
Dear Tim:
I'm from china,one of your faithful reader to the book of "Programming the Perl
DBI".
I do really enjoy and benefit a lot.
May I have your answer for a question?
#use function mdbi_execute
($r_recordset, $nrows) = mdbi_execute($dbh, $sql, 1, [EMAIL PROTECTED]);
#There is a problem.
$sql='insert into a_objects(object_id) VALUES (?)';
#the data type of the field of 'object_id' is serial(1)
(INFORMIX)
the result of this execution is that ,compare with the original values,the values
of 'object_id' were truncated .
why?
#define function mdbi_execute
sub mdbi_execute
{
my $dbh = shift;
my $sql = shift;
my $return_flag = shift;
my $parameter_list = shift;
my @parameters;
my $sth; # A SQL statement handle
my @recordset;
my @recordsets;
my $nrows;
my $i;
# Use eval to trap prepare and execute error but don't quit program
# ------------------------------------------------------------------
#print "@$parameter_list"."\n"."$sql \n";
eval
{
$sth = $$dbh->prepare($sql)
|| die "Can't prepare SQL statemant:\n\n $DBI::errstr \n\n
$sql\n\n";
# Handle the parameters_list
if(!defined $parameter_list)
{
$sth->execute()
|| die "Can't execute SQL statemant:\n\n $DBI::errstr
\n\n $sql\n\n";
}else
{
for($i = 0; $i < @$parameter_list; $i++)
{
$sth->bind_param($i+1, $$parameter_list[$i])
}
$sth->execute()
|| die "Can't execute SQL statemant b:\n\n
$DBI::errstr \n\n $sql\n\n";
}
@recordset = ();
if($return_flag == 1)
{
@recordsets = $sth->fetchrow_array;
}elsif($return_flag == 2)
{
while(@recordset = $sth->fetchrow_array)
{
push @recordsets, [EMAIL PROTECTED];
@recordset = ();
}
}
if($sth->rows == -1)
{
$nrows = 0;
}else
{
$nrows = $sth->rows;
}
$sth->finish;
};
if($@)
{
print $@;
return -1, $@;
}
if($return_flag == 0)
{
return 1, $nrows;
}elsif($return_flag == 1 || $return_flag == 2)
{
return [EMAIL PROTECTED], $nrows;
}
}
This is the first time that I enter into this forum.
I`m looking forward to your email and I do hope you could provide me with some
related information(network ,source code and materials etc).
Any help would be appreciated!
Thanks!
Yours
Paul Twa
2003/06/24
????????????
????????????????????
????????????????????????????
----- End forwarded message -----