Thanks everyone...it turned out AutoCommit was the culprit.

Looks like the Cheetah book's gonna be great light reading...
;-)

Ronald J Kimball wrote:

>On Wed, Jun 26, 2002 at 12:35:26PM -0400, James Williams wrote:
>  
>
>>Hi everyone,
>>
>>I'm running a script that is supposed to insert rows into a table, but 
>>consistantly don't do so.  I have tried both a prepare/execute and a do 
>>statement, and neither work.  
>>
>>The weird thing is, I have a conditional die statement which should 
>>print something if the execute fails, but this never works either.  I've 
>>tried printing the variables following the execute statement, so I know 
>>they are defined and I also know the environment variables are correct.
>>
>>This also happens with a delete statement but select queries work fine.
>>
>>Could someone give me some pointers I could use for troubleshooting? 
>> Some code snipets follow below.
>>
>>Thanks,
>>
>>-James
>>
>>======================================
>>sub Print_Sites_Added_Page {
>>
>>    $sth_site_stuff=$dbh->prepare("
>>         SELECT nvl(name, 'None'), type, url
>>         FROM   active
>>         WHERE  id = ?");
>>
>>    $sth_add_sites=$dbh->prepare("INSERT INTO user_sites
>>         (userid, siteid, sitename)   
>>         VALUES (?,?,?)");
>>
>>    print &PrintHeader;
>>    print p("<h3>Monitor Additional Sites:</h3>\n");
>>    print $alert;
>>    print hr();
>>    print p("The following sites have been added:");
>>    print start_form(-action => '/PA2-bin/monitored_sites.html',
>>             -method => POST), "\n";
>>
>>    foreach $sid (@new_adds) {
>>    
>>
>
>Where is @new_adds assigned?  If the array is empty, the loop will be
>skipped and $sth_add_sites will never be executed; that could be what is
>happening.
>
>  
>
>>        $sth_site_stuff->execute($sid);
>>        @row=$sth_site_stuff->fetchrow_array;
>>        ($site_name, $type, $url) = @row;
>>        $sth_add_sites->execute($uid,$sid,$site_name) || die print 
>>"Can't insert new site:<br>$DBI::errstr<hr> ";
>>    
>>
>
>This is an odd expression; you are using the return value from print as the
>argument to die, so your error message to STDERR would look like
>"1 at yourscript.pl line whatever."
>
>  
>
>>        print "<b>$type://$url</b><br>\n";
>>    
>>
>
>Hmm, if you're seeing this line in the output, that would contradict my
>theory that @new_adds is empty.
>
>Do you have AutoCommit on or off?  If off, do you call commit()?
>
>Ronald
>
>
>  
>


Reply via email to