PDO取Oracle lob大字段,当数据量太大无法取出的问题的解决办法
t_name:要查询的表名;f_name:要查询的字段名;u_id:表的主键,查询条件;l_pos:截取的开始位置; l_amount :截取长度;
CREATE OR REPLACE PROCEDURE get_clob(t_name in varchar2, f_name in varchar, u_id in integer, l_pos in integer, l_amount in BINARY_INTEGER, ReturnValue out varchar2) is
rule_xml clob;
l_buffer varchar2(3999);
l_amount_ BINARY_INTEGER;
begin
execute immediate 'select ' ||f_name|| ' from ' ||t_name|| ' where id=:1' into rule_xml using u_id;
l_amount_:=l_amount;
DBMS_LOB.read(rule_xml, l_amount_, l_pos, l_buffer);
ReturnValue := l_buffer;
end get_clob;
然后是php的处理程序:
$content = "";
$num = 0;//clob字段长度
$stmt = $oracle->prepare("select length(content) as num from test where id = $id");
if ($stmt->execute()) { //zjh为查询的条件
$row = $stmt->fetch();
$num = $row['NUM'];
}
$start = 1;//初始化开始位置
$len = 2500;//截取长度
$t_name = 'test';//操作表名
$f_name = 'content';//需要查询的clob字段名
while ($start <= $num){
$ret='';
$sql = "begin get_clob(?,?,?,?,?,?); end;";
$stmt = $oracle->prepare($sql);
$stmt->bindParam(1, $t_name, PDO::PARAM_STR, 100);
$stmt->bindParam(2, $f_name, PDO::PARAM_STR, 100);
$stmt->bindParam(3, $id, PDO::PARAM_STR, 100);
$stmt->bindParam(4, $start, PDO::PARAM_STR, 100);
$stmt->bindParam(5, $len, PDO::PARAM_STR, 100);
$stmt->bindParam(6, $ret, PDO::PARAM_STR, 5000);
$stmt->execute();
$content .= $ret;
$start=$start+$len;
}
$oracle = null;
以上就是完整的解决办法,这个方法不是俺的首创,做过pb项目的人大多数应该比较熟悉这种操作。
php操作Oracle的资料网上还是比较少的,能解决问题的就更不多了,发出来跟大家分享一下,肯定还有其他比较好的解决办法,欢迎跟大家一起探讨。
本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!
本文地址: https://v30.fanwenzhu.com/sql/oracle/2848.shtml
相关文章
热门TAG
win10 ecshop 主机 阿里云 解决 配置 C# C++ 解析 SQL语句 命令 Go语言 方法 CSS3 HTML5 CSS win7 MSSQL 服务器配置 IIS7.5 IIS7 IIS6 IIS CentOS 7 Linux oracle数据库 oracle phpcms discuz discuz教程最新文章
-
是因为scan的IP问题补占用
时间:2021-01-20
-
还你一个干净的model 2、功
时间:2021-01-20
-
既然 ROWNUM 列并不是真实存
时间:2021-01-20
-
Real Application Clusters
时间:2021-01-20
-
在tools-preferences-connection(
时间:2021-01-20
-
Windows Sever 2012下Oracle 12c安
时间:2021-01-10
-
Oracle安装监听器错误的解
时间:2021-01-07
-
oracle远程连接服务器数据
时间:2021-01-07
热门文章
-
Oracle存储过程编程详解
时间:2020-12-07
-
Azure Queue Storage 基本用法 Azure Storage 之
时间:2020-12-26
-
win10下oracle 11g安装图文教程
时间:2020-12-25
-
oracle 数据库学习 基本结构介绍
时间:2020-12-13
-
Azure File Storage 基本用法 Azure Storage 之 F
时间:2020-12-26
-
windows使用sqlpus连接oracle 数据库的教程图
时间:2020-12-25
-
Window下Oracle Database 11g 发行版2安装教程
时间:2020-12-29
-
Oracle解锁的方式介绍
时间:2020-12-14
-
Oracle 12c Study之Installer Oracle
时间:2021-01-06
-
linux下oracle设置开机自启动实现方法
时间:2020-12-13
