Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

sqldatasource dal, wwwxxxenden, convert raid5 to raid 10 mdadm, apache force chunked, nrao wwwxxx, xxxxxdup, procmail change subject header, wwwXxx not20, Wwwxxx.doks sas, linux raid resync after reboot

Links

XODOX
Impressum

#1: why does $dbh->do stmt work and not dbh->prepare

Posted on 2008-04-11 03:42:20 by mmccaws

Hi

the dbh->do stmts work but the prepare stmts don't for updates.



$dbh->do("UPDATE proj_trckr SET curr_date='$ucurrdate'
WHERE proj_id='$resetinactive' ") or die;
$dbh->do("UPDATE proj_trckr SET curr_date='$neg'
WHERE proj_id='$resetprojid' ") or die;

but these don't
------>
my $resetprojid = 'April 03, 2008';
my $resetinactive = 'INACTIVE PROJECT';
my $ucurrdate = 'yes';

my $sth= $dbh->prepare('UPDATE proj_trckr SET curr_date=?
WHERE proj_id=?');
$sth->execute($resetinactive, $ucurrdate);

my $sth= $dbh->prepare('UPDATE proj_trckr SET curr_date=?
WHERE proj_id=?');
$sth->execute($resetprojid, 'no');

----->

Thanks
Mike

Report this message

#2: Re: why does $dbh->do stmt work and not dbh->prepare

Posted on 2008-04-11 10:48:38 by Martin.Evans

mmccaws2 wrote:
> Hi
>
> the dbh->do stmts work but the prepare stmts don't for updates.
>
>
>
> $dbh->do("UPDATE proj_trckr SET curr_date='$ucurrdate'
> WHERE proj_id='$resetinactive' ") or die;
> $dbh->do("UPDATE proj_trckr SET curr_date='$neg'
> WHERE proj_id='$resetprojid' ") or die;
>
> but these don't
> ------>
> my $resetprojid = 'April 03, 2008';
> my $resetinactive = 'INACTIVE PROJECT';
> my $ucurrdate = 'yes';
>
> my $sth= $dbh->prepare('UPDATE proj_trckr SET curr_date=?
> WHERE proj_id=?');
> $sth->execute($resetinactive, $ucurrdate);
>
> my $sth= $dbh->prepare('UPDATE proj_trckr SET curr_date=?
> WHERE proj_id=?');
> $sth->execute($resetprojid, 'no');
>
> ----->

Mike,

Some things to may be look at:

1. Your do and prepare/execute examples don't look the same to me e.g.,
they use different curr_date values.

2. You don't state if you have RaiseError/PrintError set and there is no
error checking of the prepare or execute methods.

3. Have you got AutoCommit enabled because you don't state whether you
have committed your updates via prepare/execute.

Martin
--
Martin J. Evans
Easysoft Limited
http://www.easysoft.com

Report this message

#3: Re: why does $dbh->do stmt work and not dbh->prepare

Posted on 2008-04-11 13:30:46 by mdorman

On Fri, 11 Apr 2008 09:48:38 +0100
Martin Evans <martin.evans@easysoft.com> wrote:

> mmccaws2 wrote:
> > $dbh->do("UPDATE proj_trckr SET curr_date='$ucurrdate'
> > WHERE proj_id='$resetinactive' ") or die;

> > my $sth= $dbh->prepare('UPDATE proj_trckr SET curr_date=?
> > WHERE proj_id=?');
> > $sth->execute($resetinactive, $ucurrdate);
>
> Mike,
>
> Some things to may be look at:
>
> 1. Your do and prepare/execute examples don't look the same to me
> e.g., they use different curr_date values.

Even more specifically, they seem to have their values backwards---in
the ones that work $resetinactive corresponds to proj_id, but in the
latter ones he's associating that variable with curr_date.

Mike.

Report this message