普通网友 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);

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

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类