When generating a query to an Oracle database using PHP, we get the following result:

UPDATE MYTEST2 SET DESCRIPTION = 'Буmvo', NAME = 'ris' WHERE DESCRIPTION = 'Буmv'; UPDATE MYTEST2 SET DESCRIPTION = 'briz', NAME = 'Gilio' WHERE DESCRIPTION = 'briz'; 

But it fails and the error ORA-00933 is returned: SQL command not clean ended . Please tell me where I could make a mistake.

Function to form a request:

  //Редактировать таблицу public static function editTable(){ // // //$id = (int)$_POST['id']; //$namesc - имя столбца // $namesc = $_POST['id_name']; // //Новое значение // $text = $_POST['new_val']; $testArray = []; if(isset($_POST['oll_items'])){ //Новые значения строки $allIrems = $_POST['oll_items']; //столбец и значение будут использованы в кочесве индетификатора $columnAndValue = $_POST['clumn_value']; //Наименование таблицы $table = $_POST['cr_table']; //Заголовоки таблицы // $headerTable = $_POST['cr_header']; //Подключаемся к БД global $conn; $query = "UPDATE $table SET "; $query2 = "UPDATE $table SET "; $result = ""; //Изменение данных в таблице foreach ($allIrems as $item) { foreach ($item as $key => $value) { if(!next($item)){ $query .= $key . " = \"" . $value . "\" \n"; }else{ $query .= $key . " = \"" . $value . "\", \n"; } } $query .= " WHERE "; foreach ($columnAndValue as $i) { foreach ($i as $key => $value) { $query .= "$key = \"$value\""; } array_shift($columnAndValue); break; } //$result .= $query . ";\n"; // $result = str_replace("'", '', $result); // $result = str_replace('"', "'", $result); $query = str_replace("'", '', $query); $query = str_replace('"', "'", $query); // return $query; $stip = oci_parse($conn, $query); $res = oci_execute($stip); $query = ""; $query = $query2; } 

Execute query in sql plus sql plus output

  • one
    And what are you doing through this? I see here two separate requests that need to be given to the Oracle by separate function calls. And the semicolon is not needed at the end - Mike
  • With the foreach loop. If you need a function code that implements this request, add. - sn41
  • Those. one update you call at a time and there are no semicolons? Yes, it is better to give a piece of code that calls the update. Because the queries themselves are syntactically correct - Mike
  • Print the resulting query and try to execute it in some sql plus. Requests that you give at the top, for example, exactly working. Such an error as you can get can be only if the request includes something completely unexpected by syntax or not something necessary - Mike
  • 2
    We return to what I wrote the very first comment. You are trying to perform multiple updates at once. You can only perform them one by one. UPDATE MYTEST2 SET DESCRIPTION = 'Буmvo', NAME = 'ris' WHERE DESCRIPTION = 'Буmv' everything, it should stop here, it is possible to add a semicolon or / that sql plus does it. This is how you do it for several updates almost together. Of course, you will get the error that you get - Mike

0