无法使用PHP调用oracle存储过程

I am trying to call Oracle Stored Procedure from PHP. I am having two textboxes in HTML. Users providing username & password on those textboxes. After the button click, those values getting passed into PHP. PHP should pass those parameters to Oracle Stored Procedure. Both the parameters getting passed to PHP successfully. But while running Procedure, It is throwing an error. While trying to run the same procedure on SQL developer, it is working fine.

I have tried to follow the following documents - Call Oracle stored procedure from PHP

https://www.sitepoint.com/community/t/php-and-oracle-oci8-stored-procedures/7541

Oracle procedure -

create or replace 
PROCEDURE       proc_create_user (
   p_user_name   IN VARCHAR2,
   p_user_pass   IN VARCHAR2)
AUTHID  DEFINER   
IS
   lv_user_exists   INTEGER := 0;
   lv_user_name     VARCHAR2 (15) := UPPER (trim(p_user_name));
BEGIN
   SELECT COUNT (*)
     INTO lv_user_exists
     FROM dba_users
    WHERE username = lv_user_name;

   IF lv_user_exists = 0
   THEN
      EXECUTE IMMEDIATE
            'CREATE USER '
         || lv_user_name
         || ' IDENTIFIED BY '
         || p_user_pass
         || ' DEFAULT TABLESPACE USERS TEMPORARY TABLESPACE TEMP PROFILE DEFAULT ACCOUNT UNLOCK';

      EXECUTE IMMEDIATE 'GRANT CONNECT TO ' || lv_user_name;

      EXECUTE IMMEDIATE 'ALTER USER ' || p_user_name || ' DEFAULT ROLE ALL';
   ELSE
      RAISE_APPLICATION_ERROR (-20000, 'User already exists');
   END IF;
END proc_create_user;

PHP code -

<?php
// required headers
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Methods: POST");
header("Access-Control-Max-Age: 3600");

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require '../vendor/autoload.php';

foreach($_GET as $key=>$value){

}

$uid = $_GET['uid'];
$pass = $_GET['pass'];
$uidupper = strtoupper($_GET['uid']);
$uidupper = "'".$uidupper."'";
$pass = "'".$pass."'";

echo $uidupper;
echo $pass;

$db = "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=ppe.testdom.com)(PORT=1521)(SEND_BUF_SIZE=)(RECV_BUF_SIZE=))(LOAD_BALANCE=yes))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=ppe.testdom.com)))" ;
$conn = OCILogon("test", "test", $db);
$sql = 'BEGIN PROC_CREATE_USER(:p_user_name, :p_user_pass); END;';
$stmt = oci_parse($conn,$sql);                     
oci_bind_by_name($stmt,":p_user_name",$uidupper);           
oci_bind_by_name($stmt,":p_user_pass",$pass);  
echo $sql;
echo $stmt;
oci_execute($stmt);

?>

Error Details -

'ADB''abcd@1234'BEGIN DWABI.PROC_CREATE_USER(:p_user_name, :p_user_pass); END;Resource id #79<br />
<b>Warning</b>:  oci_execute(): ORA-01935: missing user or role name
ORA-06512: at &quot;DWABI.PROC_CREATE_USER&quot;, line 16
ORA-06512: at line 1 in <b>C:\xampp\htdocs\Log_Check\email_db.php</b> on line <b>48</b><br />

It will be very helpful if someone can let me know what I am doing wrong.

UPDATE: The issue has been resolved by adding DOUBLE QUOTES instead of Single Quotes.

dqf67993
dqf67993 一些有用的相关参考资料:blogs.oracle.com/opal/...和oracle.com/technetwork/topics/php/...
一年多之前 回复
duanhe7471
duanhe7471 &bartmanDilaw通过添加双引号而不是单引号解决了该问题。
一年多之前 回复
doujianwei8217
doujianwei8217 我试过这样-oci_bind_by_name($stmt,“:p_user_name”,$uidupper,32);oci_bind_by_name($语句,“:p_user_pass”,$通,32);...如果我删除单引号,它会给出错误-“oci_execute():ORA-00922:缺少或无效选项”。如果我添加单引号,则给出错误-“oci_execute():ORA-01935:缺少用户或角色名称”
一年多之前 回复
drgm51600
drgm51600 好。我会检查并告知您结果。
一年多之前 回复
dqls67891
dqls67891 是。我在SQLDeveloper中检查了TEST用户。程序正常。
一年多之前 回复
douji4223
douji4223 “test”用户是否具有CREATEUSER角色?对我而言,这不是一个PHP问题,但Oracle会给出问题。您是否在SQL会话(连接测试)中启动了PROC_CREATE_USER?
一年多之前 回复
douwa1304
douwa1304 你能否更新绑定到oci_bind_by_name($stmt,“:p_user_name”,$uidupper,32);(如oracle.com/technetwork/articles/fuecks-sps-095636.html上的示例)-这也没有单引号。
一年多之前 回复
douhui9631
douhui9631 PROC_CREATE_USER(:p_user_name,:p_user_pass);END;资源ID#79<br/><b>警告</b>:oci_execute():ORA-00922:缺少或无效选项ORA-06512:at“DWABI.PROC_CREATE_USER”,第16行ORA-06512:at<b>C:\xampp\htdocs\Log_Check\email_db.php</b>中的第1行<b>48</b><br/>。你需要像这样运行Proc-BEGINDWABI.PROC_CREATE_USER('ttt','trert');结束;多数民众赞成为何添加“'”
一年多之前 回复
dongnuo3749
dongnuo3749 你需要$uidupper=“'”中的单引号。$uidupper。“'”;和密码?
一年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问