在ASP中,如何存储大于4000字节的数据类型开ORACLE数据库中!库中的字段类型我用的是CLOB大字符类型!但是提示说字符串字节过长!
解决方案 »
- 怎么使用C#读取数据库视图user_views的text字段?数据类型为long,现在读取到C#后显示空
- oracle数据库,安装过程中,怎么改变其字符集
- ORACLE数据库的几个问题,视图更新,索引效率,insert执行过程。。
- VC++ 2005开发环境下,怎么连接oracle数据库?急!
- 请问:oracle中的表、数据文件和段、区,之间,有什么联系呢?
- 数据泵导出时报错
- 关于调试
- 请问怎样修改参数log_archive_start=true
- 关于oracle在windows xp上的安装问题
- 请问ORACLE9i的SQL*PLUS和SQL*PLUSWorkSheet是不是不能同时开启用?我发现它们之间的不能相互更新??
- 高分求助:能否自己编写一个oracle性能分析工具?
- oracle7的数据如何导入到oracle9i中?
你比如:有一个变量是传递大字符的,如何用INSERT INTO 到一个表中
比如:INSERT INTO ASDF1(A,B) VALUES('"&A&"',)省略号中怎么写??
通过BUFFER将字节流写入代码是如何写的??
请多多指教!!!我给分的!谢谢!
connection.committrans()
connection.rollbacktrans()可能有点不一样,应该差不多。sql = "insert into t (a,b),values(1,empty_clob())"你应该是用"ADODB.Recordset"的吧。那个对象应该有写入字节流的方法。(很久没写ASP了,记不清了)
你不用Buffer,直接一下子写进去是可以的,
不过太大的文件(几M),一下写不太好(但是我是过1、2M直接写入是可以的)。
习惯上是一段一段写比较好。如果你的文件不是很大,直接写好了。
insert以后,还要将刚才那条记录Select出来。通过记录集再将内容写入到这个字段。最后提交事务。
这一句代码中没有传递大字符的变量,也可以吗?
我用的是ADODB。RECORDSET
文件没有那么大,能存上个几万中文就可以了!
我用了你说的方法,但是好像存不上的!
多谢你了!sql = "insert into t (a,b),values(1,empty_clob())"就这样写吗?
用字节流写入就会写到分配好的数据区了。insert和select 出来修改必须在同一事务中完成。
strdata=strdata & request.Form("hdnbigfield" & i)
next
s="insert into ASDF(a,b) VALUES('"&a&"',empty_clob())"
cn.execute(s)
还要添加什么代码?兄弟,请你多教一下!
很关键的!谢谢!
在ASP中怎么选记录,选完之后怎么通过记录集、数据流再写入分配好的CLOB数据区呢!
然后循环执行 rs("b").AppendChunk bufferappendchunk 的使用方法参见http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdamth01_3.asp
Good luck
最重要的是执行insert和后来的update必须在一个事务里。cn.begintrans
insert ..... select ....
rs.updatecn.committrans发生错误要执行cn.rollbacktrans
strdata=strdata & request.Form("hdnbigfield" & i)
next
a=request.form("a")
Set rs=Server.CreateObject("ADODB.RecordSet")
cn.begintrans
s="insert into ASDF(a,b) VALUES('"&a&"',empty_clob())"
cn.execute(s)
rs.open ("select b from asdf where a ='"&a&"' for update"),cn,3,2
rs("b").AppendChunk strdata
rs.update()
cn.committrans
为什么数据会丢失,例如:strdata 变量为1000个字节,可是存入数据库时只有650个字节!
我倒是没有用ASP写过Oracle的大文本。你是用GetChunk获取写入的数据么?还有就是试试看不用AppendChunk。直接用rs("b")=strdata。我再帮你试试看吧。给分到帖子的管理里面就可以了。
你再试试看吧。Reference: ASP: Articles: ADO, Oracle and (Text in) BLOBs
Questions to Karen WallaceThis tutorial covers loading a text into a BLOB using Oracle's OLEDB Provider. Why on earth, you make ask, would you want to do that when you could just put the text in a CLOB? Maybe you have data that could be text or binary and should all go into the same table because it's related and has the same properties. Real life example: You allow users to store HTML and images in the database for simple webpages. Yes, you could just store the images on disk, but you have a web farm and you don't want to deal with deployment and undeployment to and from multiple servers, and the traffic on these pages will be light. In other words, you're lazy and looking to program something new.If you've read the related tutorial on storing binary data in BLOBs, you'll find this very similar.I. Load the Text Data into the Database
Get an updatable recordset and shove the text into the recordset. As working with LOBs of any sort involves transactions whether you want them or not, it's advisable to wrap your databasing in a transaction. Always initialize your BLOB field with empty_blob().<%
dim conn, rsset conn = server.createObject("adodb.connection")
conn.open "Provider=OraOLEDB.Oracle;Data Source=oracle.mydomain.com;User ID=scott;PASSWORD=tiger"set rs = server.createObject("adodb.recordset")conn.beginTrans'Use this for an update
conn.execute "UPDATE blobtable SET blobcolumn = empty_blob() WHERE id = 7"
rs.open "SELECT blobcolumn FROM blobtable WHERE id = 7", conn, adOpenStatic, adLockOptimistic'Or this for an insert
conn.execute "INSERT INTO blobtable (id, blobcolumn) VALUES (blobtable_seq.nextVal, empty_blob())"
rs.open "SELECT blobcolumn FROM blobtable WHERE id = blobtable_seq.currVal", conn, adOpenStatic, adLockOptimisticrs.fields("blobcolumn").appendChunk(lotsOfText)
rs.update
rs.closeconn.commitTrans
%>II. Retrieve the Text Data from the Database
You can write to the browser or to disk. Streams default to UTF-8, which might not match your database's character set, you must convert it. Plus, the ASP engine doesn't like to read unicode.<%
dim conn, rsset conn = server.createObject("adodb.connection")
conn.open "Provider=OraOLEDB.Oracle;Data Source=oracle.mydomain.com;User ID=scott;PASSWORD=tiger"set rs = conn.execute("SELECT blobcolumn FROM blobtable WHERE id = 7")'Write it to the browser
response.write rs.fields("blobcolumn").value'Write it to disk
dim stream
set stream = server.createObject("adodb.stream")
stream.type = adTypeText
stream.charset = "iso-8859-1"
stream.open
stream.writeText(rs.fields("blobcolumn").value)
stream.saveToFile folderAndFileName, adSaveCreateOverWrite
stream.close
%>
http://www.fawcette.com/china/print.aspx?TotalPage=6&ID=76