Problem control Transaction in Oracle

From: satit <satit_at_thambun.com>
Date: 27 Jul 2002 23:02:40 -0700
Message-ID: <3bf33fbf.0207272202.58054142_at_posting.google.com>


Help me please. I would like to lock row for control user . 1. If I add condition before update_data() (remove // from code)when commit data can't update.
2. function select_data can't lock row but if I use oracle sql*plus to lock by sqlcommand "select * from users where account=... for update" program can wait until I commit on sql*plus.

Is their other method to lock row ?

Thank you

my code:

function commit($conn)
{ ocicommit($conn);
  echo $conn." committed\n\n";
}

function select_data($c1,$account){
 $gcom ='select * from admin.USERS where account = '."'".$account."' for update nowait";
$result = OCIParse($c1, $gcom);

    $chk = OCIExecute($result,OCI_DEFAULT);

      $nrows = OCIFetchStatement($result,$results);
      for ( $i = 0; $i < $nrows; $i++ ) {
      reset($results);      
      $s = 0;
      while ( $column = each($results) ) {   
         $data = $column['value'];
		 $gdata[$s] = $data[$i];
		 echo '-'.$gdata[$s];
		 $s++;
		 }

   }
  }

function update_data($conn,$code,$newdata){ $new="update admin.users set lname='".$newdata."' where account='".$code."'";
$stmt = ociparse($conn,$new);
  ociexecute($stmt,OCI_DEFAULT);
  echo $conn." update hallo\n\n";
}

 $c1 = ocilogon($us,$pass,$database);
 $c2 = ocilogon($us,$pass,$database);

select_data($c1,$account);

// if ($stats=="save"){
update_data($c1,$account,$count);
//}

if($stats=="commit"){

   commit($c1);
}

 echo '<form method="post" action="dusers.php" name="">';
 echo' <input type="submit" name="stats" value="save">';
 echo' <input type="submit" name="stats" value="commit">';
 echo '</form>';
Received on Sun Jul 28 2002 - 08:02:40 CEST

Original text of this message