|
发表于 2006-8-25 00:00:56
|
显示全部楼层
") m_strDest = replace (m_strDest , "++" , "||") call print ("[AnalyseKeyword()]:处理多个减号完毕后m_strDest = '" + m_strDest + "'")
'处理加号两边的空格 m_strDest = replace(m_strDest , " +" , "+") m_strDest = replace(m_strDest , "+ " , "+") m_strDest = replace(m_strDest , " + " , "+") call print ("[AnalyseKeyword()]:处理减号两边的空格完毕后m_strDest = '" + m_strDest + "'")
'-------------------------------处理加号完毕-----------------------------
'-------------------------------处理多个减号及减号两边的空格问题-----------------------------
'处理多个减号的问题,遇到多个减号则认为是字符串,而不是逻辑符 m_strDest = replace (m_strDest , "---" ,"~~~") m_strDest = replace (m_strDest , "--" , "~~")
call print ("[AnalyseKeyword()]:处理多个减号完毕后m_strDest = '" + m_strDest + "'")
'处理减号两边的空格 m_strDest = replace(m_strDest , " -" , "-") m_strDest = replace(m_strDest , "- " , "-") m_strDest = replace(m_strDest , " - " , "-") call print ("[AnalyseKeyword()]:处理加号两边的空格完毕后m_strDest = '" + m_strDest + "'")
'-------------------------------处理减号完毕-----------------------------
'------------------------------处理字符串两头的加减号问题----------------- if len(m_strDest) >= 3 then m_strHead = left(m_strDest , 1) m_strMiddle = mid(m_strDest , 2 , len(m_strDest) - 2) m_strTail = right(m_strDest , 1) if m_strHead = "+" or m_strHead = "-" then m_strHead = "" end if if m_strTail = "+" or m_strTail = "-" then m_strTail = "" end if m_strDest = m_strHead + m_strMiddle + m_strTail end if '----------------------------处理完毕------------------------------------- m_strDest = replace(m_strDest , "--" , "~~") m_strDest = replace(m_strDest , "++" , "||") m_strDest = replace(m_strDest , chr(32) , "@") AnalyseKeyword = m_strDest call print ("[AnalyseKeyword()]:全部处理完毕后m_strDest = '" + m_strDest + "'")
end function %>
存储过程 /*********************************************************************/ /* proc name : Up_ParseWordSearch */ /* */ /* Description: 关键字搜索 */ /* */ /* parameters: @a_strCategoryID 分类id */ /* @a_intPosition 调用的位置 */ /* @a_strParseWord 搜索关键字 */ /* @a_intRowCount 限定最多取得记录数 */ /* */ /* date: 2000/6/28 */ /* */ /* author: Liuyunpeng */ /* */ /* history: */ /*********************************************************************/
if exists (select * from sysobjects where id = object_id("up_ParseWordSearch")) drop proc up_ParseWordSearch go
create proc up_ParseWordSearch @a_strParseword varchar(255) , @a_strCategoryID varchar(255) , @a_intPosition tinyint , @a_intRowCount int as declare @m_strSqlCondition varchar(255) --Sql语句的条件部分 declare @m_strSqlSelect varchar(255) --Sql语句的选择部分 declare @m_strSqlCategory varchar(100) --sql语句的分类部分
/*根据调用位置决定sql的选择部分*/ select @m_strSqlSelect = case when @a_intPosition = 4 then --商品库 "select ProductID , 'Title' = ProductName , 'Description' = left(Description , 100) " + " from Product where " when @a_intPosition = 5 then --商业机会库 "select ID , Title ,'Description' = left(convert(varchar,content) , 100) " + " from BusinessChance where " when @a_intPosition = 6 then --公司库 "select CompanyID , 'Title' = CompanyName , 'Description' =left(Description , 100) " + " from Company where " end
/*根据分类ID决定sql的分类部分*/ select @m_strSqlCategory = case when @a_strCategoryID <> "0" then " CategoryID like '" + @a_strCategoryID + "%' and " else "" end
/*根据调用位置决定sql的条件部分*/ select @m_strSqlCondition = case when @a_intPosition = 4 --商品 then "(ProductName like '%" + @a_strParseWord + "%'" + " or Description like '%" + @a_strParseWord + "%'" + " or ProducerName like '%" + @a_strParseWord + "%') " when @a_intPosition = 5 --商业机会 then "(Title like '%" + @a_strParseWord + "%'" + " or Keyword like '%" + @a_strParseWord + "%') " when @a_intPosition = 6 then "(CompanyName like '%" + @a_strParseWord + "%'" + " or Description '%" + @a_strParseWord + "%') " end
set rowcount @a_intRowCount exec (@m_strSqlSelect + @m_strSqlCategory + @m_strSqlCondition) set rowcount 0 go
|
|