jsp+oracle处理大字段内容时:某些内容可以录入,某些提示错误

shinco1 2005-04-17 09:41:04
jsp+oracle处理大字段内容时:某些内容可以录入,某些提示错误能但能录入内容的一部分,表格录入不正常,哪位帮我看看那个存储过程是否有问题,
由于是别人写的,能否给解释一下请问大家在处理大字段时格式化录入内容有些什么好的方法和例子,供小弟参考参考!
1.yfblr.jsp:
<%@ page language="java" contentType="text/html;charset=gb2312"%>
<%@ page import="java.util.*" %>
<%@ page import="pub.*" %>
<%@ include file="checksession1.jsp" %>
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="../images/style.css" type="text/css">
<script>
function checkpost()
{
document.form2.news.value=document.frames.doc_html.getHTML(true)
return true
}
function dis(s)
{
if (document.all["xz"].style.display=="none")
document.all["xz"].style.display=""
}
</script>
</head>

<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<%@ include file="top.jsp"%>
<table width="780" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td colspan="2" bgcolor="#9e9e9e" height="3"></td>
</tr>
<tr>
<td colspan="2"><img src="" width="1" height="1"></td>
</tr>
<tr>
<td background="../images/bg_a.gif" height="355" valign="top">
<table width="620" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td colspan="2"> </td>
</tr>
<form name="form2" method="post" action="yfblr_do.jsp" onsubmit="checkpost();">
<tr>
<td colspan="2">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr bgcolor="#dddddd">
<td bgcolor="#dddddd" height="20" width="86%"><img src="../images/arrow1.gif" width="15" height="11"><span class="a1">专栏信息录入</span></td>
<td align="center"> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td width="80">所属栏目:</td>
<td width="540">
<select name="columnid">
<option value="1">金研报告</option>
<option value="2">民安视点</option>
<option value="3">周报月报</option>
<option value="4">中线股票池</option>
<option value="5">短线股票池</option>
<option value="6">营业部视点</option>
<option value="7">期货专栏</option>
<option value="8">其它投资品种</option>
</select>
</td>
</tr>
<tr>
<td width="80">标  题:</td>
<td width="540">
<input type="text" name="title" size="60">
</td>
</tr>
<tr>
<td width="80">出  处:</td>
<td width="540">
<input type="text" name="source" size="20">
</td>
</tr>
<tr>
<td width="80">作  者:</td>
<td width="540">
<input type="text" name="author" size="20" >
</td>
</tr>
<tr>
<td width="80">发布日期:</td>
<td width="540">
<input type="text" name="inputtime" size="20" value="<%=global.formatDate("yyyy/MM/dd HH:mm",new java.util.Date()) %>" >
</td>
</tr>
<tr>
<div style="display:none" id=org_doc> </div>
<td colspan="2" valign="top"> 文章内容:<br>
<iframe width=620 height=350 id="doc_html" src=htmledit.htm></iframe>
</td>
</tr>
<tr align="center">
<td colspan="2" height="38">
<input type="submit" name="Submit" value=" 提交 ">
<input type="reset" name="Submit2" value=" 重置 " onclick="javascript:document.frames.doc_html.setHTML('<div></div>')">
</td>
</tr>
<input type = "hidden" name = "news">
</form>
</table>
<br>
<p> </p></td>
</tr>
</table>
</body>
</html>
2.yfblr_do.jsp:
<%@ page language="java"
import="java.util.*,pub.*"
contentType="text/html;charset=gb2312"%>
<%@ page import="java.util.*" %>
<%@ page import="pub.*" %>

<%
String columnid = request.getParameter("columnid");
//String levelid = request.getParameter("levelid");
String title = request.getParameter("title");
String source = request.getParameter("source");
String author = request.getParameter("author");
String inputtime = request.getParameter("inputtime");
String content = request.getParameter("news");
//String userid = (String)session.getValue("userid");

RecordSet rs = new RecordSet();
char separator = rs.separator;
String cmd = title + separator + columnid + separator + inputtime + separator + author + separator + source + separator + content;
//System.out.println(cmd);
rs.executeWriteClob("proc_Mayfb_WriteNews", cmd);
int subflag = rs.getFlag();
String msg = "录入成功!";
if(subflag != 0)
{
msg = rs.getMsg();
}
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="../images/style.css" type="text/css">
</head>

<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<%@ include file="top.jsp"%>
<table width="780" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td align="center" background="images/bg_2.gif" height="355" valign="top">
<p> </p><br>
<%=msg%><%=cmd%></td>
</tr>
</table>
</body>
</html>
3.CREATE OR REPLACE PROCEDURE Proc_Mayfb_WriteNews
(
ptitle varchar2,
pcolumnid varchar2,
pinputtime varchar2,
pauthor varchar2, --作者
psource varchar2,
pcontent varchar2,
RET_FLAG OUT NUMBER,
RET_MSG OUT VARCHAR2,
RET_CUR IN OUT Defpkg.EMPTY_CUR,
isold number
)
Is
v_num number;
v_titleid varchar2(38);
loc_clob clob;
amt binary_integer:=32767;
BEGIN
RET_FLAG := 0;
RET_MSG := '成功!';
savepoint s1;
if isold > 0 then
select seq_titleid.nextval into v_num from dual;
v_titleid:=to_char(v_num-isold);
select content into loc_clob from t_yfbnews_content where wzid=v_titleid for update;
dbms_lob.writeappend(loc_clob,amt,pcontent);
else
select seq_titleid.nextval into v_num from dual;
v_titleid:=to_char(v_num);
insert into t_yfbnews(titleid,title,columnid,source,author,inputtime) values(v_titleid,ptitle,pcolumnid,psource,pauthor,to_date(pinputtime,'yyyy/mm/dd hh24:mi'));
insert into t_yfbnews_content(wzid,content) values(v_titleid,pcontent);
end if;
commit;
open ret_cur for select 1 from dual;

EXCEPTION
WHEN OTHERS THEN
BEGIN
RET_FLAG := 101;
RET_MSG := '错误';
rollback to s1;
END;
END Proc_Mayfb_WriteNews;
...全文
113 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
shinco1 2005-04-25
  • 打赏
  • 举报
回复
谁能帮忙解释一下 amt binary_integer:=32767;
BEGIN
RET_FLAG := 0;
RET_MSG := '成功!';
savepoint s1;
if isold > 0 then
select seq_titleid.nextval into v_num from dual;
v_titleid:=to_char(v_num-isold);
select content into loc_clob from t_yfbnews_content where wzid=v_titleid for update;
dbms_lob.writeappend(loc_clob,amt,pcontent);
else
yupingping 2005-04-22
  • 打赏
  • 举报
回复
up
shinco1 2005-04-22
  • 打赏
  • 举报
回复
---------------------------------------新闻录入表------------------------------------
create table t_yfbnews(
titleid int not null, --文章编号
title varchar2(300), --文章标题
columnid varchar2(10), --栏目类别(1 2 3 4 5 6 7 8)
source varchar2(40), --出处
author varchar2(40), --作者
inputtime date default sysdate, --录入时间
isvaild varchar2(1) default '1' , --是否废弃 0-废 1-用
primary key(titleid)
)
tablespace D_USER
pctfree 20
pctused 60
storage (initial 16K
next 16K
freelists 10
freelist groups 2);
CREATE SEQUENCE seq_titleid INCREMENT BY 1 START WITH 1 MAXVALUE 99999999 NOCYCLE NOCACHE ORDER;

--------------------------------------新闻内容表--------------------------------------------------
create table t_yfbnews_content(
wzid int not null, --文章编号
content CLOB , --文章内容
isvaild varchar2(1) default '1' --是否废弃 0-废 1-用
)
tablespace D_USER
pctfree 20
pctused 60
storage (initial 128K
next 64K
freelists 10
freelist groups 2);
shinco1 2005-04-18
  • 打赏
  • 举报
回复
求助啊,谁乱发广告
shinco1 2005-04-18
  • 打赏
  • 举报
回复
找不出来原因啊,都是套用的呢,谁能帮我啊
thrive_li 2005-04-18
  • 打赏
  • 举报
回复
存储过程错误就用toad或者sqlplus先调试,看看错在哪里
marksmile 2005-04-18
  • 打赏
  • 举报
回复
字符过长要把字段类型设置为clob或blob
whycloud 2005-04-18
  • 打赏
  • 举报
回复
在oracle中,如果一个字段是字符型的,当他长度过长的时候(当然还没有超出表中设置的长度)不可以直接存储,而是需要设置相应的参数才可以。你可以查一下oracle的技术手册,上面应该有
shinco1 2005-04-17
  • 打赏
  • 举报
回复
直接返回了ret_msg='错误'啊,存储过程那里是直接返回了异常
woodcord 2005-04-17
  • 打赏
  • 举报
回复
提示什么错误信息啊?/

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧