CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: DBI:
update table in oracle db

 



ms10380
Novice

Feb 15, 2010, 7:53 AM

Post #1 of 2 (5520 views)
update table in oracle db Can't Post

I have the function below that is supposed to update an existing table. I do not get any errors when I execute the script, however when I go back and try to verify that the update was successful, the entry is not in the table. I am connecting to an oracle database using the DBI module.

Thanks



sub update_cmds {

my $name = shift;

my $value = shift;

my $sth = undef;

my $sql_statement = "UPDATE SET_CMDS SET SET_VALUES=\'$value\', LAST_ACK_TIME=NULL WHERE SET_NAME=\'$name\' ";

unless ($sth=$dbh->prepare($sql_statement)) {

$dbh->rollback;

log_off_oracle($dbh);

exit;

}

unless ($sth->execute()) {

$dbh->rollback;

log_off_oracle($dbh);

exit;

}

}


Nila
User


Mar 8, 2010, 1:42 AM

Post #2 of 2 (5042 views)
Re: [ms10380] update table in oracle db [In reply to] Can't Post

Try to check your AutoCommit property in your code.


Code
my $dbh = DBI->connect( "dbi:Oracle:$db", $username, $passwd ) ||           die( $DBI::errstr . "\n" ); 
$dbh->{AutoCommit} = 0;


AutoCommit: when set to 1, DBI issues a commit after each successful SQL statement. This is very dangerous and on by default. Setting it to 0 is a good idea.
If you set it to '0' then you need to commit every successful SQL statement.


(This post was edited by Nila on Mar 9, 2010, 5:18 AM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives