I'll repeat what I said earlier, can you SELECT from this database prior
to the INSERT? I can't see where the problem is, have you read the DBI
doco? That has a nice trace function which can be used in this
circumstance. It allows you to see the SQL prior to it being sent to the
server, the response from the server etc.

I highly recommend a read. Just as an aside, we obviously live in
different time zones (I'm in Australia) and don't look at emails later
at night because I tend to sleep 8-)

Regards 


David Logan
Database Administrator
HP Managed Services
148 Frome Street,
Adelaide 5000
Australia

+61 8 8408 4273 - Work
+61 417 268 665 - Mobile
+61 8 8408 4259 - Fax


-----Original Message-----
From: Gerald Preston [mailto:[EMAIL PROTECTED] 
Sent: Monday, 28 February 2005 8:41 AM
To: Logan, David (SST - Adelaide); mysql@lists.mysql.com
Subject: RE: insert data

David,

I just cannot believe what a pain this is.  I got past the prepare with
no
errors by doing the following:

  my $dbh = DBI->connect( 'DBI:mysql:database=club', 'xxxxxxx',
'xxxxxxx', {
PrintError => 0 } ) or die $DBI::errstr;
  my $sql = "insert into wolfies( group_name, me, daily, item, unit,
qty,
amount, tax, total )
                          values( ?,          ?,  ?,     ?,    ?,    ?,
?,
?,   ?     ) ";
  my $sth = $dbh->prepare( $sql ) or die $dbh->errstr if $dbh->err;

  $sth->execute( $group_name, $me, $daily, $item, $unit, $qty, $amount,
$tax, $total ) or warn "Cannot execute FIRST Statement!!\n$DBI::errstr";

I just do not believe this, but I get the same error (almost ):

"Can't call method "execute" on an un undefined value"

Jerry

-----Original Message-----
From: Logan, David (SST - Adelaide) [mailto:[EMAIL PROTECTED] 
Sent: Sunday, February 27, 2005 3:27 PM
To: Gerald Preston; mysql@lists.mysql.com
Subject: RE: insert data

Hi Gerald,

The only thing I can think of is that you have a syntax error in your
SQL that hasn't showed up in translation to email. Are you able to
select from the database prior to the INSERT? This would confirm that
your db has made a successful connection.

The placeholders etc. work exactly as they do in the oracle version of
the DBI.

Regards

David Logan
Database Administrator
HP Managed Services
148 Frome Street,
Adelaide 5000
Australia

+61 8 8408 4273 - Work
+61 417 268 665 - Mobile
+61 8 8408 4259 - Fax


-----Original Message-----
From: Gerald Preston [mailto:[EMAIL PROTECTED] 
Sent: Monday, 28 February 2005 7:49 AM
To: [EMAIL PROTECTED]; mysql@lists.mysql.com
Subject: RE: insert data

The object used:

  my $dbh=DBI->connect( 'DBI:mysql:database=club', 'xxx, 'xxxxx', {
PrintError => 0} ) or die $DBI::errstr;

Jerry

-----Original Message-----
From: John Doe [mailto:[EMAIL PROTECTED] 
Sent: Sunday, February 27, 2005 6:37 AM
To: mysql@lists.mysql.com
Subject: Re: insert data

Hi Gerald

> I am trying to insert data for the first time using MySQL.  In Oracle
I
> used the following:
>
> #  my $sql = "insert into bar( group_name, me, daily, item, unit, qty,
> amount, tax, total )
>
> #                      values( ?,          ?,  ?,     ?,    ?,    ?,
?,
> ?,   ? ) ";
>   my $sth = $dbh->prepare( $sql );
>   die $dbh->errstr if $dbh->err;
>   $sth->execute( $group_name, $me, $daily, $item, $unit, $qty,
$amount,
> $tax, $total ) || die "Cannot execute FIRST
Statement!!\n$DBI::errstr";
>
>
> I keep getting "Can't call method "prepare" on an un undefined value.
All
> the name listed are correct by looking at MySQLAdmin1.3\4.

Apart from David Logan's answer:

You have to create the $dbh object first (man DBI); the "undefined
value" in

the error message refers to that.


HTH

joe

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]





-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]






--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to