dryift6733 2018-09-17 15:09
浏览 96

使用变量Clob在Out中运行函数时出错(PHP,Oracle,Laravel)

I have an application developed with the Laravel php framework. And I use the following package to work with my oracle database. https://github.com/yajra/laravel-oci8

I have the following function in oracle:

function my_func(uid in number, json in out nocopy clob) return number is

And in php I call it that

$result = '';

$pdo = DB::connection('oracle')->getPdo();

$stmt = $pdo->prepare("begin :result := my_func(:uid, :json); end;");
$stmt->bindParam(':result', $result, \PDO::PARAM_INT);
$stmt->bindParam(':uid', $uid, \PDO::PARAM_INT);
$stmt->bindParam(':json', $json, \PDO::PARAM_STR, 1000000);
$stmt->execute();

return response()->json(json_decode($json), ($result === 1) ? 200 : 
400);

When the output of 'json' is smaller than 32767 characters, then the code works. But when it is greater the following exception occurs:

Oci8Exception {#615
#message: """
Error Code : 6502

Error Message : ORA-06502: PL/SQL: erro numérico ou de valor

System details Oracle 11g

Ubuntu 18.04

PHP 7.2

Laravel 5.5

Laravel-OCI8 5.5

  • 写回答

1条回答 默认 最新

  • dousi6087 2018-09-17 19:43
    关注

    I was able to develop a solution. Not sure if it is the best, but it worked.

    $result = $lob = '';
    
    $pdo = DB::connection('oracle')->getPdo();
    
    $stmt = $pdo->prepare("declare v_uid number(10) := :uid; v_data clob := :data; begin :result := my_func(v_uid, v_data); :lob := v_data; end;");
    
    $stmt->bindParam(':result', $result, \PDO::PARAM_INT);
    $stmt->bindParam(':uid', $uid, \PDO::PARAM_INT);
    $stmt->bindParam(':data', $data, \PDO::PARAM_STR);
    $stmt->bindParam(':lob', $lob, SQLT_CLOB);
    $stmt->execute();
    
    $json = $lob->read($lob->size());
    
    return response()->json(json_decode($json), ($result === 1) ? 200 : 400);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图