OCI_INVALID_HANDLE 总是为 OCI-Lob::save() 返回

OCI_INVALID_HANDLE always returned for OCI-Lob::save()

我从 php 收到以下警告:"OCI-Lob::save(): OCI_INVALID_HANDLE" 第 38、39 行

<?php
  $lob_e = oci_new_descriptor($connection, OCI_D_LOB);
  $lob_w = oci_new_descriptor($connection, OCI_D_LOB);


  $stid = oci_parse($connection, "
            UPDATE RES_LICENCE_TEXT T
          SET
            LICENCE_TEXT_EN =   EMPTY_CLOB(),
            LICENCE_TEXT_CY =   EMPTY_CLOB(),
            updated_by = :my_updated_by,
            updated_date = SYSDATE

        WHERE T.hall_Seq = :my_hall_seq
        and :my_academic_year = academic_year
        and :my_app_period = app_period
        and step_name = 'assoc_instr'
        and :offer_id = offer_id

      RETURNING LICENCE_TEXT_EN,LICENCE_TEXT_CY INTO :CLOBDATA_E, :CLOBDATA_W");

    oci_bind_by_name($stid, ':MY_ACADEMIC_YEAR', $_SESSION['chosen_year']);
    oci_bind_by_name($stid, ':MY_APP_PERIOD',  $_SESSION['chosen_app_period']);
  oci_bind_by_name($stid, ':offer_id',      $offer_id);
    oci_bind_by_name($stid, ':MY_HALL_SEQ',      $_SESSION['hall_seq']);

    oci_bind_by_name($stid, ':CLOBDATA_E',  $lob_e, -1, OCI_B_CLOB);
    oci_bind_by_name($stid, ':CLOBDATA_W',  $lob_w, -1, OCI_B_CLOB);
    oci_bind_by_name($stid, ':my_updated_by',  $_SESSION['loguser']);


    $success = oci_execute($stid, OCI_DEFAULT);

    if (!$success) {
        oci_rollback($connection);
        $text_insertion_error = 0;
    } else {
        $lob_e->save($html_e_string);
        $lob_w->save($html_w_string);
        oci_commit($connection);
        $text_insertion_error = 1;
    }

    oci_free_descriptor($lob_e);
    oci_free_descriptor($lob_w);
    oci_free_statement($stid);


?>

有问题的行是:$lob_e->save($html_e_string);和 $lob_w->保存($html_w_string); 我可以得到一些帮助吗? 干杯

您的 WHERE 子句不匹配任何行。该语句成功匹配 0 行,因此遵循 else 分支,但 LOB 定位器未与行关联并且不可用。

尝试将逻辑更改为:

if (!$success) {
    oci_rollback($connection);
    $text_insertion_error = 0;
} else if (oci_num_rows($stid) === 1) {
    $lob_e->save($html_e_string);
    $lob_w->save($html_w_string);
    oci_commit($connection);
    $text_insertion_error = 1;
}

您几乎肯定想要添加一个额外的 else 分支(即当 oci_num_rows($stid) > 1 时)以引发错误。