doulong2782 2015-11-19 08:39
浏览 47

从PHP运行Oracle过程会返回错误数量或类型的参数错误

I am trying to troubleshoot one piece of PHP code that simply calls one of the Oracle procedures. Now, I don't know a thing about Oracle procedures, I just need this procedure to be called with 2 parameters and return hardcoded value. I started with create a package and a dummy procedure:

CREATE OR REPLACE 
PACKAGE TESTAPI1 AS 
  PROCEDURE GETTEST;
END EMAILAPI1;

CREATE OR REPLACE PROCEDURE GETTEST(p1 IN VARCHAR, p2 IN CLOB) AS 
BEGIN
  NULL;
END GETTEST;

PHP code that calls this procedure looks like this:

$stid = oci_parse($this->conn, "begin testapi1.gettest(:p1, :p2); end;");
$clob = oci_new_descriptor($this->conn, OCI_D_LOB); 

oci_bind_by_name($stid, ':p1', "some string", 4000, SQLT_CHR);
oci_bind_by_name($stid, ':p2', $clob, -1, SQLT_CLOB);

$r = oci_execute($stid);

And after running this code, I'm getting this error:

 [code] => 6550
    [message] => ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'GETTEST'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
    [offset] => 6
    [sqltext] => begin testapi1.gettest(:p1, :p2); end;

Can anybody tell me what's wrong this code?

  • 写回答

1条回答 默认 最新

  • doubi4531 2015-11-19 16:05
    关注

    I noticed some issues which I hope will assist you:

    1. your package identifiers must match
    2. your package procedure must include a parameter list so that the signature matches the procedure.

    See below for changes. This code now compiles w/o errors.

    CREATE OR REPLACE
    PACKAGE TESTAPI1 AS
      PROCEDURE GETTEST(p1 VARCHAR, p2 CLOB);
    END TESTAPI1;
    /
    
    CREATE OR REPLACE PROCEDURE GETTEST(p1 IN VARCHAR, p2 IN CLOB) AS
    BEGIN
      NULL;
    END GETTEST;
    /
    
    评论

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向