ストレージプロセスは複雑で複雑ですが、複数の論理文字をサポートできます。このテーブルで検索し、ストアドプロシージャの速度を最適化することを選択できます。それでは、ASPのコード実装と、ストアドプロシージャのプログラムを検索するストアドプロシージャのコード実装を知っていますか? Foot New Technologyチャンネルの編集者に、それについてもっと学びましょう!
ASP関数
コードコピーは次のとおりです。関数AnalyseKeyWord(a_strsource)
dim m_strdest、m_intloop
dim m_intbeginpos、m_intendpos
dim m_strhead、m_strmiddle、m_strtail
m_strdest = a_strsource
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'最初に端のスペースを取り外します
m_strdest = ltrim(rtrim(m_strdest))
'& "and"などを +、 - 、スペースで交換します
M_STRDEST =置換(M_STRDEST、 "&"、 "+")
M_STRDEST =置換(M_STRDEST、 "and"、 "+")
m_strdest = cheplage(m_strdest、 "or"、chr(32))
m_strdest = cheplage(m_strdest、 "not"、 " - ")
'変数を初期化して、次のループを移動します
M_INTBEGINPOS = 1
M_INTBEGINPOS <> 0を実行します
M_INTBEGINPOS = INSTR(M_STRDEST、CHR(32))
M_INTBEGINPOS <> 0の場合、スペースが見つかった場合
m_strhead = rtrim(ltrim(左(m_strdest、m_intbeginpos))))
call print( "[AnalyseKeyword()]:スペースm_stread =" + m_strhead)を処理する
m_strtail = rtrim(ltrim(right(m_strdest、len(m_strdest)-m_intbeginpos))))
call print( "[AnalyseKeyword()]:スペースm_strtail =" + m_strtail)を処理する
m_strdest = m_strhead + "*" + m_strtail
それ以外
終了します
ifを終了します
ループ
m_strdest = cheplage(m_strdest、 "*"、chr(32))
call print( "[AnalyseKeyword()]:スペースを処理した後、m_strdest =" + m_strdest)
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'最初に、単一の引用を二重引用符で置き換えます
M_STRDEST =交換(M_STRDEST、CHR(39)、CHR(34))
'初期値を設定して、ループを移動させます
M_INTBEGINPOS = 1
M_INTENDPOS = 1
m_strhead = ""
m_strtail = ""
M_INTBEGINPOS <> 0およびM_INTENDPOS <> 0を実行します
「二重引用符が見つかった場合は、開始位置に注意して、次の二重引用を探します
M_INTBEGINPOS = INSTR(M_STRDEST、CHR(34))
M_INTBEGINPOS <> 0の場合、最初の引用が見つかった場合
call print( "[AnalyseKeyWord()]:最初の引用が表示される場所:" + cstr(m_intbeginpos))
M_INTENDPOS = strust(m_intbeginpos + 1、m_strdest、chr(34))
M_INTENDPOS <> 0の場合、2回目の引用が見つかった場合
call print( "[AnalyseKeyword()]:2番目の見積もりが表示されます:" + cstr(m_intendpos))
「文字列全体を引用符で3つの段落に分けます
call print( "[AnalyseKeyWord()]:引用符m_strdest =" + m_strdest)を処理する
m_strhead = left(m_strdest、m_intbeginpos -1)
call print( "[AnalyseKeyword()]:引用符m_strhead =" + m_strhead)を処理する
m_strmiddle = mid(m_strdest、m_intbeginpos + 1、m_intendpos -m_intbeginpos -1)
call print( "[AnalyseKeyword()]:引用符m_strmiddle =" + m_strmiddle)を処理する
m_strtail = right(m_strdest、len(m_strdest)-m_intendpos)
call print( "[AnalyseKeyword()]:m_strtail =" + m_strtail)
'引用符に +サインがある場合、それはキャラクターとして処理され、他のキャラクターに一時的に置き換えられます
m_strmiddle =置換(m_strmiddle、 "+"、 "|")
m_strdest = m_strhead +置換(rtrim(ltrim(m_strmiddle))、chr(32)、 "#") + m_strtail
それ以外
終了します
ifを終了します
それ以外
終了します
ifを終了します
ループ
M_STRDEST =置換(M_STRDEST、CHR(34)、 "+")
call print( "[AnalyseKeyword()]:引用符を処理した後、m_strdest =" + m_strdest)
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
「複数のプラスサインのトラブルシューティング、複数のプラスサインが発生した場合、それは文字列であり、論理的な文字ではないと思います
m_strdest = cheplage(m_strdest、 "+++"、 "|||")
m_strdest = cheplage(m_strdest、 "++"、 "||")
call print( "[AnalyseKeyWord()]:複数のマイナスサインを処理した後、m_strdest = '" + m_strdest + "'")
'プラス記号の両側のスペースを扱います
M_STRDEST =置換(M_STRDEST、 " +"、 " +")
M_STRDEST =置換(M_STRDEST、 "+"、 "+")
M_STRDEST =置換(M_STRDEST、 " +"、 " +")
call print( "[AnalyseKeyword()]:マイナス記号の両側のスペースを処理した後、m_strdest = '" + m_strdest + "'")
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
「複数のマイナスサインのトラブルシューティング、複数のマイナスサインに遭遇した場合、それは論理的な文字ではなく、文字列であると思うでしょう
m_strdest = cheplage(m_strdest、 "---"、 "~~~~")
m_strdest = cheplage(m_strdest、 " - "、 "~~")
call print( "[AnalyseKeyWord()]:複数のマイナスサインを処理した後、m_strdest = '" + m_strdest + "'")
'マイナス記号の両側のスペースを扱います
M_STRDEST =置換(M_STRDEST、 " - "、 " - ")
M_STRDEST =置換(M_STRDEST、 " - "、 " - ")
M_STRDEST =置換(M_STRDEST、 " - "、 " - ")
call print( "[AnalyseKeyword()]:プラス記号の両側のスペースを処理した後、m_strdest = '" + m_strdest + "'")
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
len(m_strdest)> = 3の場合
m_strhead = left(m_strdest、1)
m_strmiddle = mid(m_strdest、2、len(m_strdest)-2)
m_strtail = right(m_strdest、1)
m_strhead = "+"またはm_strhead = " - " thenの場合
m_strhead = ""
ifを終了します
m_strtail = "+"またはm_strtail = " - " thenの場合
m_strtail = ""
ifを終了します
m_strdest = m_strhead + m_strmiddle + m_strtail
ifを終了します
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
m_strdest = cheplage(m_strdest、 " - "、 "~~")
m_strdest = cheplage(m_strdest、 "++"、 "||")
M_STRDEST =置換(M_STRDEST、CHR(32)、 "@")
AnalyseKeyWord = M_STRDEST
call print( "[AnalyseKeyword()]:すべての処理が完了した後、m_strdest = '" + m_strdest + "'")
エンド関数
%>
ストアドプロシージャ
/**********************************************/
/ * proc名:up_parsewordsearch */
/ * */
/ *説明:キーワード検索 */
/ * */
/ *パラメーター:@a_strcategoryidカテゴリID */
/ * @a_intposition呼び出し場所 */
/ * @a_strparsewordキーワードの検索 */
/ * @a_introwcountレコードの最大数を制限して取得する */
/ * */
/ *日付:2000/6/28 */
/ * */
/ *著者:liuyunpeng */
/ * */
/* 歴史: */
/**********************************************/
存在する場合(select * from sysobjects where id = object_id( "up_parsewordsearch"))
ドロップup_parsewordsearch
行く
proc up_parsewordsearch @a_strparseword varchar(255)を作成します。
@a_strcategoryid varchar(255)、
@a_intposition tinyint、
@a_introwcount int
として
@M_STRSQLCONDITION VARCHAR(255)宣言 - SQLステートメントの条件付き部分
@M_STRSQLSELECT VARCHAR(255) - SQLステートメント選択パーツを宣言します
@M_STRSQLCATEGORY VARCHAR(100) - SQLステートメントのカテゴリ部分を宣言します
/*通話場所に基づいてSQLの選択部分を防御*/
@M_STRSQLSELECTを選択します
=ケース
@a_intposition = 4 then -productライブラリ
「select productid、 'title' = productname、 'description' = left(description、100)」
+「製品から」
@a_intposition = 5の場合 - - ビジネス機会ライブラリ
「id、title、 'description' = left(convert(varchar、content)、100)」を選択します」
+「ビジネスチャンスから」
@a_intposition = 6の場合、 - コンパニーライブラリ
「select companyid、 'title' = companyname、 'description' = left(description、100)」
+「会社から」
終わり
/*分類IDに基づいてSQLの分類部分を防御します*/
@m_strsqlcategoryを選択します
=ケース
@a_strcategoryid <> "0" "" categoryid like '" + @a_strcategoryid +"%' and "
それ以外 ""
終わり
/*呼び出し場所に基づいてSQLの条件付き部分を決定*/
@M_STRSQLCONDITIONを選択します
=ケース
@a_intposition = 4 -product
次に」( "%" + @a_strparseword + "% '"
+「または「%」のような説明 + @a_strparseword + "% '"
+「または「%」のようなプロデューサー名 + @a_strparseword + "% ')"
@a_intposition = 5の場合 - ビジネスの機会
次に」( '% " + @a_strparseword +"%' "
+「または「%」のようなキーワード + @a_strparseword + "% ')"
@a_intposition = 6の場合
次に」
+ "または説明 '%" + @a_strparseword + "%')"
終わり
rowcount @a_introwcountを設定します
exec(@m_strsqlselect + @m_strsqlcategory + @m_strsqlcondition)
rowcount 0を設定します
行く
上記は、ASPおよびストアドプロシージャにおける検索プログラムのコード実装です。誰もが特定の理解を持っていると思います。より多くの技術情報を知りたい場合は、間違った新しいテクノロジーチャネルに注意を払い続けてください!