隼の空
2011年8月8日 星期一
[ORACLE]如何新增 BLOB/CLOB ?
CREATE
TABLE
article(
subject
VARCHAR2
(
50
char
),
content CLOB ,
tstamp
TIMESTAMP
DEFAULT
SYSDATE
);
--
使用EMPTY_CLOB()来初始化CLOB字段
String strSql
=
"
INSERT
INTO
article(subject,content)
VALUES
(
'
文章標題:Empty_clob()的使用方法
'
,EMPTY_CLOB())";
Connection conn
=
db.getConnection();
conn.setAutoCommit(false);
PreparedStatement ptmt
=
conn.prepareStatement(sqlBuffer.toString());
ptmt.executeUpdate();
strSql
=
"
select
content
from
article
where
subject
=
"
+
subject
+
"
for
update
";
ResultSet rs
=
ptmt.executeQuery(strSql);
if
(rs.
next
()) {
/*
取出此CLOB物件
*/
oracle.sql.CLOB clob
=
null
;
clob
=
(oracle.sql.CLOB) rs.getClob("content");
/*
向CLOB
物件中寫入資料
*/
BufferedWriter out
=
new BufferedWriter(clob.getCharacterOutputStream());
out.write(content);
out.
close
();
out
=
null
;
沒有留言:
張貼留言
較新的文章
較舊的文章
首頁
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言