12
返回列表 发新帖
楼主: armying

一个数据类型长度的问题,始终无法解决,请教各位啦!

[复制链接]
论坛徽章:
21
ITPUB元老
日期:2005-02-28 12:57:002012新春纪念徽章
日期:2012-02-13 15:11:182012新春纪念徽章
日期:2012-02-13 15:11:182012新春纪念徽章
日期:2012-02-13 15:11:182012新春纪念徽章
日期:2012-02-13 15:11:18马上有车
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:142012新春纪念徽章
日期:2012-02-13 15:11:18
11#
发表于 2001-12-17 17:56 | 只看该作者
长度是肯定容易超过2500直接的。但是long确实比较难办。
用clob应该容易一点。

例子:
long:
insert into long_tables values (lpad'('just test for long',8000,'*'));

使用道具 举报

回复
论坛徽章:
5
授权会员
日期:2005-10-30 17:05:332009新春纪念徽章
日期:2009-01-04 14:52:282013年新春福章
日期:2013-02-25 14:51:242014年新春福章
日期:2014-02-18 16:41:11马上有车
日期:2014-02-18 16:41:11
12#
发表于 2001-12-17 23:53 | 只看该作者
如果在SQL*PLUS,用'||'来CONCATENATE字符串;
如果用JDBC,先把字符串写入一个TEXT文件,然后用IOSTREAM读写

使用道具 举报

回复
论坛徽章:
0
13#
 楼主| 发表于 2001-12-18 14:01 | 只看该作者

能不能介绍一下使用php如何插入数据(>4000byte)?

都快急死我了!

使用道具 举报

回复
论坛徽章:
21
ITPUB元老
日期:2005-02-28 12:57:002012新春纪念徽章
日期:2012-02-13 15:11:182012新春纪念徽章
日期:2012-02-13 15:11:182012新春纪念徽章
日期:2012-02-13 15:11:182012新春纪念徽章
日期:2012-02-13 15:11:18马上有车
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:142012新春纪念徽章
日期:2012-02-13 15:11:18
14#
发表于 2001-12-18 20:49 | 只看该作者
用||不行吗?我没有用过php,应该也支持sql这样写吧?
其实换成lob可能是更好的选择,从长远来看。

使用道具 举报

回复
论坛徽章:
2
ITPUB元老
日期:2005-02-28 12:57:00授权会员
日期:2005-10-30 17:05:33
15#
发表于 2001-12-19 07:02 | 只看该作者
Have you tried to run the script under DOS or UNIX, like sqlplus userid=scott/tiger@orcl @test.sql?

使用道具 举报

回复
论坛徽章:
2
ITPUB元老
日期:2005-02-28 12:57:00授权会员
日期:2005-10-30 17:05:33
16#
发表于 2001-12-19 07:03 | 只看该作者
My other thought would be using SQL loader to load the data.

使用道具 举报

回复
论坛徽章:
3
ITPUB元老
日期:2005-02-28 12:57:00授权会员
日期:2005-10-30 17:05:33ITPUB9周年纪念徽章
日期:2010-10-08 09:32:25
17#
发表于 2001-12-19 11:34 | 只看该作者

by procedure

通过procedure或许可以,sqlplus毕竟还是有许多限制,将你的数据通过call procedure可以存储到DB,尤其是数据比较特殊的时候!good luck!

使用道具 举报

回复
论坛徽章:
2
授权会员
日期:2005-10-30 17:05:332011新春纪念徽章
日期:2011-01-04 10:35:48
18#
发表于 2001-12-19 13:18 | 只看该作者
Problem Description:  
====================  

When inserting a string literal into a long or varchar2 field, you get the
error ORA-01704 STRING LITERAL TOO LONG.
example:
insert into table (..., long_column, ...) values (..., 'A really really long
hardcoded string which is inside single quotes', ...);


Problem Explanation:  
====================  

String literals are limited to 2000 characters.
If the string inside the single quotes is more than 2000 characters, you will
get this error.  Note that this is not the length of the entire SQL statement,
just the length of the hardcoded string.

Solution Description:
=====================

Use a bind variable instead of a string literal.                              
  
This can only be done with the precompilers or OCI.

Solution Explanation:
=====================

For example, this is a solution in Pro*C:                                      
  
                                                                                
EXEC SQL begin declare section;                                                
  
  varchar long_val[10000];  /* Bind variable to store the column value */      
  
EXEC SQL end declare section;                                                  
  
                                                                                
  strcpy(long_val.arr, "A really really long hardcoded string which used to \  
  
         be inside single quotes";                                            
  
  long_val.len = strlen(long_val.arr);   

EXEC SQL insert into table (..., long_column, ...)                             
  values (..., :long_val, ...);  


Note the use of the bind variable, rather than the hardcoded string.
.
So , you know how to program PHP?r
Hi, Guys, more questions please
Jim IT Pub 第一击:[/SIZE]

使用道具 举报

回复
论坛徽章:
0
19#
发表于 2001-12-19 15:39 | 只看该作者
你可以试着使用BFILE类型嘛。

使用道具 举报

回复
论坛徽章:
25
ITPUB元老
日期:2005-02-28 12:57:00咸鸭蛋
日期:2013-02-07 11:51:42咸鸭蛋
日期:2013-02-08 09:48:51蜘蛛蛋
日期:2013-02-21 15:47:392013年新春福章
日期:2013-02-25 14:51:24咸鸭蛋
日期:2013-02-28 17:08:42蜘蛛蛋
日期:2013-03-29 16:17:14双黄蛋
日期:2013-04-11 16:11:04咸鸭蛋
日期:2013-05-07 11:55:14咸鸭蛋
日期:2013-05-28 10:46:24
20#
发表于 2001-12-20 11:03 | 只看该作者
在SQLPLUS中没有办法,
用程序应该用BIND方式,
JDBC中用setCharacterStream即可

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表