简体   繁体   English

如何将整数传递给ORACLE数据库?

[英]How can I pass an integer to an ORACLE database?

I have to pass parameters as Numbers from php to ORACLE. 我必须将参数作为Numbers从php传递到ORACLE。 Is there any way to do that ? 有什么办法吗? Cause I need to delete the row with the ID that is given. 原因我需要删除具有给定ID的行。 But if I try oci_by_name I get: "numeric or value error: character to number conversion error ORA-06512" 但是,如果我尝试oci_by_name,则会得到:“数字或值错误:字符到数字的转换错误ORA-06512”

Here is my code 这是我的代码

<?php   
$conn = oci_connect('DBadmin', 'dbadmin', 'PETLOVERSDB');
if (!$conn) {
    $e = oci_error();
    trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}    
        $deleteOption = $_GET['selectedId'];     
        $CategorySelected = $_GET['selectedOption'];

        if($CategorySelected == "Pet Type"){  
            $stid = ociparse($conn, "BEGIN  setting_package.DELETE_Type(:p1); END;");
        }  
        oci_bind_by_name($stid, ':p1', $deleteOption);
        oci_execute($stid); 
        oci_close($conn);

?>   

Any suggestions would be appreciated. 任何建议,将不胜感激。

Depends what setting_package.DELETE_Type procedure expect. 取决于期望的setting_package.DELETE_Type过程。 If this is a VARCHAR2 then you could handle it inside that PL/SQL routine, but otherwise I would pre-check in PHP and only pass a number, otherwise the PL/SQL call will crash with I think a ORA-01722: not a valid number or so. 如果这是VARCHAR2则可以在该PL/SQL例程中处理它,但是否则,我将在PHP预检查并仅传递一个数字,否则PL/SQL调用将因我认为ORA-01722: not a valid number左右。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM