简体   繁体   中英

How can I pass an integer to an ORACLE database?

I have to pass parameters as Numbers from php to ORACLE. Is there any way to do that ? Cause I need to delete the row with the ID that is given. But if I try oci_by_name I get: "numeric or value error: character to number conversion error 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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