php訪問oracle寫sql不能換行

2022-07-31 10:09:12 字數 715 閱讀 1987

當begin和end存在的時候,寫sql不能存在換行,似乎是在處理sql的時候出問題了,如果換行會導致語法錯誤。

如下程式是錯誤的

$sql="begin 

update com_customer set exp_score=case when (nvl(exp_score,0)".$score_str.")<0 then 0 else nvl(exp_score,0)".$score_str."  end,last_changed_date=sysdate

where customer_id=:customer_id;

end;";

$sth = db::commwritedb()->prepare($sql);

$sth->bindparam(":customer_id",$cust_id);

$result = $sth->execute();

$sth->closecursor();

把sql換成這樣就是正確的了:="begin   update com_customer set exp_score=case when (nvl(exp_score,0)".$score_str.")<0 then 0 else nvl(exp_score,0)".$score_str."  end,last_changed_date=sysdate where customer_id=:customer_id;end;";

pdo還是無法處理換行符。

PHP訪問Oracle資料庫

說明 oracle資料庫帳號 stic oracle資料庫密碼 stic oracle資料庫例項 orcl oracle資料庫表 userinfo oracle表的列 id,name 不處理異常的 如下 建立資料庫連線 建立資料庫連線 conn oci connect stic stic orcl ...

配置Oracle訪問SQL地理資料庫

arcsde是arcgis的空間資料引擎,它是在關聯式資料庫管理系統 rdbms 中儲存和管理多使用者空間資料庫的通路。以前連線方式有兩種,服務連線與直接連線 簡稱 直連 兩種在不同arcgis版本中用軟體與 連線方式部落格中也總結了一些 但現在,沒有了arcsde伺服器了,即沒有了服務連線,只有直...

Oracle動態SQL返回值傳到變數的寫法

網上找到很多寫法,有些對有些不對,自己摸索,找到一些可以通過測試的寫法,總結如下 均以hr schema舉例 1.普通的select返回 1 declare 2 v name employees.last name type 3 v salary number 4 p id employees.em...