2013-01-23 66 views
6

我有以下INSERT查詢ORA-01036;非法的變量名/編號

include("ORCLconfig.php"); 

$addAclaim = oci_parse($conn, "INSERT INTO claims_accidents (ID, CLAIM_NUMBER, DATE_OF, TIME, LOCATION, PURPOSE, WEATHER, ROAD, STREET_LIGHTS, SPEED_LIMIT, SPEED_PRIOR, SPEED_AT_MOMENT, AIRBAGS, AMBULANCE, SIGNALS, OCCUPANTS, DESCRIPTION, ROAD_LOCATION, PH_DRIVING, NAME_OF_DRIVER, DRIVER_DOB, DRIVER_OCCUPATION, MEDICAL_CONDITIONS, DRIVER_CONVICTIONS, AUTHORISED, DRIVER_ADDRESS1, DRIVER_ADDRESS2, DRIVER_ADDRESS3, DRIVER_ADDRESS4, DRIVER_POSTCODE, DRIVER_TELEPHONE, MATCH, V5_NUMBER, KEY_SETS, OS_FINANCE, VEHICLE_VALUE, VEHICLE_REG, VEHICLE_MAKE, VEHICLE_MODEL, NAMED_DRIVER, FATALITIES, DRIVEABLE) VALUES (null, :claimnum, :date_of_accident, :time_of_acc, :location_of_acc, :purpose, :weather, :road, :lights, :speedLimit, :speedPrior, :speedImpact, :airbags, :ambulance, :signals, :occupants , :accdesc, :street_of_acc :ph_driving, :driverName, :DRIVER_DOB, :driverOccupation, :driverMedical, :driverConvictions, :auth, :driverAddress1, :driverAddress2, :driverAddress3, :driverAddress4, :driverPostcode, :driverTelephone, :match, :v5number, :keySets, :osf, :vehicle_value, :vehicle_reg, :vehicle_make, :vehicle_model, :named, :fatal, :driveable)"); 

    oci_bind_by_name($addAclaim, ":claimnum", $claimnum); 
    oci_bind_by_name($addAclaim, ":date_of_accident", $date_of_accident); 
    oci_bind_by_name($addAclaim, ":time_of_acc", $time_of_acc); 
    oci_bind_by_name($addAclaim, ":location_of_acc", $location_of_acc); 
    oci_bind_by_name($addAclaim, ":purpose", $purpose); 
    oci_bind_by_name($addAclaim, ":weather", $weather); 
    oci_bind_by_name($addAclaim, ":road", $road); 
    oci_bind_by_name($addAclaim, ":lights", $lights); 
    oci_bind_by_name($addAclaim, ":speedLimit", $speedLimit); 
    oci_bind_by_name($addAclaim, ":speedPrior", $speedPrior); 
    oci_bind_by_name($addAclaim, ":speedImpact", $speedImpact); 
    oci_bind_by_name($addAclaim, ":airbags", $airbags); 
    oci_bind_by_name($addAclaim, ":ambulance", $ambulance); 
    oci_bind_by_name($addAclaim, ":signals", $signals); 
    oci_bind_by_name($addAclaim, ":occupants", $occupants); 
    oci_bind_by_name($addAclaim, ":accdesc", $accdesc); 
    oci_bind_by_name($addAclaim, ":street_of_acc", $street_of_acc); 
    oci_bind_by_name($addAclaim, ":ph_driving", $ph_driving); 
    oci_bind_by_name($addAclaim, ":driverName", $driverName); 
    oci_bind_by_name($addAclaim, ":DRIVER_DOB", $DRIVER_DOB); 
    oci_bind_by_name($addAclaim, ":driverOccupation", $driverOccupation); 
    oci_bind_by_name($addAclaim, ":driverMedical", $driverMedical); 
    oci_bind_by_name($addAclaim, ":driverConvictions", $driverConvictions); 
    oci_bind_by_name($addAclaim, ":auth", $auth); 
    oci_bind_by_name($addAclaim, ":driverAddress1", $driverAddress1); 
    oci_bind_by_name($addAclaim, ":driverAddress2", $driverAddress2); 
    oci_bind_by_name($addAclaim, ":driverAddress4", $driverAddress4); 
    oci_bind_by_name($addAclaim, ":driverPostcode", $driverPostcode); 
    oci_bind_by_name($addAclaim, ":driverTelephone", $driverTelephone); 
    oci_bind_by_name($addAclaim, ":match", $match); 
    oci_bind_by_name($addAclaim, ":v5number", $v5number); 
    oci_bind_by_name($addAclaim, ":keySets", $keySets); 
    oci_bind_by_name($addAclaim, ":osf", $osf); 
    oci_bind_by_name($addAclaim, ":vehicle_value", $vehicle_value); 
    oci_bind_by_name($addAclaim, ":vehicle_reg", $vehicle_reg); 
    oci_bind_by_name($addAclaim, ":vehicle_make", $vehicle_make); 
    oci_bind_by_name($addAclaim, ":vehicle_model", $vehicle_model); 
    oci_bind_by_name($addAclaim, ":named", $named); 
    oci_bind_by_name($addAclaim, ":fatal", $fatal); 
    oci_bind_by_name($addAclaim, ":driveable", $driveable); 

    oci_execute($addAclaim, OCI_COMMIT_ON_SUCCESS); 

每次我嘗試運行此查詢我得到這個錯誤

oci_bind_by_name(): ORA-01036: illegal variable name/number 

我已經做了一些調查,這是顯然它意味着其中一個變量不在SQL語句中。對我來說情況並非如此,我已經檢查了語句,DB(這是oracle)表和所有綁定變量,它們都匹配。

錯誤的行號將表明它是$ driveable變量。我做了一個支票,並將其發送到頁面上。

不知道在哪裏看,所以任何幫助將是偉大的。

回答

18

你似乎已經在這裏漏掉了一個逗號,

:street_of_acc :ph_driving, 

它應該是,

:street_of_acc, :ph_driving, 
+3

怎麼我錯了!它現在完美工作雖然:)謝謝。我會在9分鐘內接受你回答,當它讓我:) – jampez77

+4

我們只有兩隻眼睛,我相信你現在看到這個代碼重複一遍又一遍......令人驚訝的是:它發生..很高興所有的好。 – bonCodigo

2

除了@bonCodigos回答,你不結合:driverAddress3

+0

斑點,我也會添加一個:) – jampez77

+0

這也是一個很好的接收,但錯誤不是由於*沒有綁定* =) – bonCodigo

+1

@ jampez77:我同意bonCodigo,他的回答是更正確的,所以應該是被接受的。 – beny23

0

如果你也有視覺工作室,你正在使用細節視圖。我建議重新配置你的數據源。我正在收到ORA-01036錯誤,而我所要做的只是重新配置我的SQL源,併爲我正確生成了它。對我而言,當我嘗試更新數據源時,我沒有正確處理原始值。

我也在Oracle。

相關問題