Home > database >  How to realize the pinyin query in PB
How to realize the pinyin query in PB

Time:09-20

For example I type B can be automatically listed in the database of Beijing, the north, and so on B pinyin at the beginning of the content?
Don't use pinyin to the method in the table,,, too tired
I saw a function but not call the Internet ah, who can help
Function is as follows:
create function f_GetPy(@str nvarchar(4000)) returns nvarchar(4000) as begin declare @strlen int,@re nvarchar(4000) declare @t table(chr nchar(1) collate Chinese_PRC_CI_AS,letter nchar(1)) insert into @t(chr,letter) select '吖 ', 'A ' union all select '八 ', 'B ' union all select '嚓 ', 'C ' union all select '咑 ', 'D ' union all select '妸 ', 'E ' union all select '发 ', 'F ' union all select '旮 ', 'G ' union all select '铪 ', 'H ' union all select '丌 ', 'J ' union all select '咔 ', 'K ' union all select '垃 ', 'L ' union all select '嘸 ', 'M ' union all select '拏 ', 'N ' union all select '噢 ', 'O ' union all select '妑 ', 'P ' union all select '七 ', 'Q ' union all select '呥 ', 'R ' union all select '仨 ', 'S ' union all select '他 ', 'T ' union all select '屲 ', 'W ' union all select '夕 ', 'X ' union all select '丫 ', 'Y ' union all select '帀 ', 'Z ' select @strlen=len(@str),@re=' ' while @strlen> @ re=0 begin select top 1 letter + @ re, the from @ @ strlen=@ strlen - 1 t where a CRH & lt;=the substring (@ STR, @ strlen, 1) order by CRH desc if @ @ rowcount=0 select @ re=the substring (@ STR, @ strlen, 1) + @ re, @ strlen=@ strlen - 1 end return (@ re) end




Function has been added to the database
My original query is
String s
S="%" + trim (sle_name. Text) + "%
"Dw_3. Setfilter (" year="+ string (currentyear) +" and name like '" + s + "' ")
Dw_3. Filter ()
Dw_3. Retrieve ()
Now want to change to pinyin,

CodePudding user response:

"Beijing" data when added to the database, such as to set up the corresponding pinyin. So at the time of use, as long as according to input pinyin, realize progressive type hints.

CodePudding user response:

For prompt limited data, appropriate use pinyin method.

CodePudding user response:

Well checked

CodePudding user response:

Will you lose people get a function to convert 'north' s B pinyin can s=f_GetPy (s)

CodePudding user response:

It is not necessary to save database, although I don't have specific for this feature, but I talk about my train of thought:
1. The use of pinyin initials function for search letters correspond to the two Chinese characters: for example, type "B", get the corresponding word "eight" and "clean"
2. To find the qualified record: oracle, for example: select * from tabName where substr (colName, 1, 1) & gt;="eight" and substr (colName, 1, 1) & lt; "Brush";

Attached: take a function of pinyin initials f_get_firstLetter (), can reverse flexibility for the required function
/* 
Function:
For Chinese characters, pinyin initials
Parameters:
As_hz: Chinese character string
The return value:
Successful return to initials; Returns an empty string failure
*/

Long ll_pos
String ls_py


For ll_pos=1 to Len (as_hz)
Choose case mids (as_hz ll_pos, 1)
The case is & gt;="turn"; Ls_py +="z"
The case is & gt;="ya". Ls_py +="y"
The case is & gt;="evening"; Ls_py +="x"
The case is & gt;="wow"; Ls_py +="w"
The case is & gt;="he"; Ls_py +="t"
The case is & gt;="and"; Ls_py +="s"
The case is & gt;="but"; Ls_py +="r"
The case is & gt;="7". Ls_py +="q"
The case is & gt;="on". Ls_py +="p"
The case is & gt;="oh"; Ls_py +="o"
The case is & gt;="get"; Ls_py +="n"
The case is & gt;="mama"; Ls_py +="m"
The case is & gt;="profile"; Ls_py +="l"
The case is & gt;="cafe"; Ls_py +="k"
The case is & gt;="clause"; Ls_py +="j"
The case is & gt;=""; Ls_py +="h"
The case is & gt;="ga"; Ls_py +="g"
The case is & gt;="hair"; Ls_py +="f"
The case is & gt;="um"; Ls_py +="e"
The case is & gt;="a"; Ls_py +="d"
The case is & gt;="brush"; Ls_py +="c"
The case is & gt;="eight"; Ls_py +="b"
The case is & gt; O=""; Ls_py +="a"

In case the else
Ls_py +=Mid (as_hz ll_pos, 1)
The end choose
Next


Return ls_py

CodePudding user response:

Can I use pinyin search inside the database function, and then fuzzy

http://blog.csdn.net/zeeeitch/article/details/6087281

CodePudding user response:

According to the letter back to the Chinese characters do not display well

Dw_3. Setfilter (" year="+ string (currentyear) +" and name like '" + s + "' ")

Change

Dw_3. Setfilter (" year="+ string (currentyear) +" and f_get_firstLetter (name) like '" + s + "' ")

CodePudding user response:

Table ~ ~ ~ ~
  • Related