求一个有关于字段内容长度的SQL语句或存储过程

smallflaybird 2004-11-11 11:10:18
现有一个存储过程.要求把TITLE字段里面的内容长度小于指定长度的记录选择出来放出游标.
但是我这样写的不正确.应该怎么写呢?
TopicRecord is ref CURSOR;
Procedure GetBestTopicList(
nPageSize in number,
MaxLength in number,
topicCursor out TopicRecord,
sResult out number
)IS
nLength integer;
Begin
Open topicCursor For
select topicid,title,boardid,locktopic,postusername,postuserid,dateandtime,
hits,votetotal,istop,lastposttime,isbest,isvote,lastpostusername,
lastpostuserid,bbscount,isdelete,bbsboard,topicimg,t_color
From
(
Select topicid,title,boardid,locktopic,postusername,postuserid,dateandtime,
hits,votetotal,istop,lastposttime,isbest,isvote,lastpostusername,
lastpostuserid,bbscount,isdelete,bbsboard,topicimg,t_color
From bbs_tb_bbsTopic t
--下面的lengthb(title) > MaxLength不正确
Where t.isbest = 1 and lengthb(title) > MaxLength
order by t.dateandtime desc
)
where rownum <= nPageSize;
sResult := 0;
exception
when others then
Sresult := -1000104;
return;
END GetBestTopicList;
...全文
83 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
smallflaybird 2004-11-11
  • 打赏
  • 举报
回复
楼上的米明白偶的意思..偶是指
--下面的lengthb(title) > MaxLength不正确
Where t.isbest = 1 and lengthb(title) > MaxLength
这里没有达到我要求的TITLE内容只有小于指定大小先择出来
bluelamb 2004-11-11
  • 打赏
  • 举报
回复
改用动态的sql
str:='select topicid,title,boardid,locktopic,postusername,postuserid,dateandtime,
hits,votetotal,istop,lastposttime,isbest,isvote,lastpostusername,
lastpostuserid,bbscount,isdelete,bbsboard,topicimg,t_color
From
(
Select topicid,title,boardid,locktopic,postusername,postuserid,dateandtime,
hits,votetotal,istop,lastposttime,isbest,isvote,lastpostusername,
lastpostuserid,bbscount,isdelete,bbsboard,topicimg,t_color
From bbs_tb_bbsTopic t
--下面的lengthb(title) > MaxLength不正确
Where t.isbest = 1 and lengthb(t.title) >'|| MaxLength||'
order by t.dateandtime desc
) where rownum <= '||nPageSize;
open topicCursor for str;
smallflaybird 2004-11-11
  • 打赏
  • 举报
回复
顶一个...

17,086

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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