普通网友 2015-04-10 17:58
浏览 88
已采纳

PHP / PDO调用json中输出CLOB的过程

How can I have the output CLOB from my stored procedure when I call it with PDO driver in PHP?

The procedure is define like this in Oracle:

PROCEDURE COPI_SCHE(P_ID    IN   LOCT_SCHE.ID%TYPE,
                     P_SCHE  OUT  CLOB) 

Where LOCT_SCHE.ID%TYPE is NUMBER (10)

If I call it with TOAD it works:


    DECLARE
    test CLOB;
    BEGIN
    LOC_SH.COPI_SCHE(884, TEST);
    dbms_output.put_line(test);
    END

;

The output result:

{ "ID" : "915", "FK_RA_NO_PERM" : "1234567", "TYPE_SCHE" : "PLP", "DESC_SCHE" : "test 4", "AN" : "", "TIMB_MAJ" : "15-04-10", "USAG_MAJ" : "USER" }

So, in PHP, I try this:


    $connection = $this->getConnection();
    $idGrouping = 884;
    $sql = "CALL LOC_SH.COPI_SCHE(?,?)";        
    $statement = $connection->prepare($sql);
    $statement->bindParam(1, $idGrouping, PDO::PARAM_INT);
    $statement->bindParam(2, $result, PDO::PARAM_LOB);
    $statement->execute();

But Oracle throw:

ORA-06553: PLS-306: wrong number or types of arguments in call to 'COPI_SCHE'

What's wrong?

I try many associations with PDO::PARAM_LOB|PDO::PARAM_INPUT_OUTPUT but nothing works.

Thanks for help.

  • 写回答

1条回答

  • doujiaozhan4397 2015-04-14 13:06
    关注

    Finally got it by myself.

    I don't know why but PDO::PARAM_LOB doesn't work in this case.

    The solution is to use PDO::PARAM_STR like that:

    $statement->bindParam(2, $result, PDO::PARAM_STR, 2048);

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 易语言把MYSQL数据库中的数据添加至组合框
  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况