ORA-01036;非法变量名称/编号
Posted
技术标签:
【中文标题】ORA-01036;非法变量名称/编号【英文标题】:ORA-01036; illegal variable name/number 【发布时间】:2013-01-06 23:14:51 【问题描述】:我有以下插入查询
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 语句中。这不是我的情况,我检查了语句、数据库(即 oracle)表和所有绑定的变量,它们都匹配。
错误上的行号表明它是 $driveable 变量。我进行了检查,并且正在将其发送到页面。
不知道还能去哪里看,所以任何帮助都会很棒。
【问题讨论】:
【参考方案1】:你好像漏掉了一个逗号,
:street_of_acc :ph_driving,
应该是,
:street_of_acc, :ph_driving,
【讨论】:
我怎么错过了!!它现在可以正常工作了:) 谢谢。当它允许我时,我会在 9 分钟内接受你的回答 :) 我们只有两只眼睛,我敢肯定,现在一遍又一遍地查看这段代码,你的眼睛会感到困惑...... :D 它发生了......很高兴一切都好。【参考方案2】:除了@bonCodigos 的回答,你没有绑定:driverAddress3
【讨论】:
很好看,我也会添加一个:) 这也是一个很好的捕获,但是由于不绑定而没有产生错误=) @jampez77:我同意bonCodigo,他的答案是最正确的,所以应该是被接受的。 我不同意,因为我的脚本中的代码实际上包含了所有变量。我一定是在格式化问题时不小心删除了它,所以唯一的错误是@bonCodigo 看到的那个【参考方案3】:如果您也有 Visual Studio 并且正在使用详细信息视图。我建议重新配置您的数据源。我收到了 ORA-01036 错误,我所要做的就是重新配置我的 SQL 源,它会为我正确生成它。对我来说,当我尝试更新我的数据源时,我没有正确处理原始值。
我也在甲骨文。
【讨论】:
以上是关于ORA-01036;非法变量名称/编号的主要内容,如果未能解决你的问题,请参考以下文章