Tutorials to .com

Tutorials to .com » Asp » Database » Arabic numerals the amount of conversion of the stored procedure for the Chinese

Arabic numerals the amount of conversion of the stored procedure for the Chinese

Print View , by: iSee ,Total views: 11 ,Word Count: 500 ,Date: Tue, 26 May 2009 Time: 6:10 PM

Create Procedure AtoC
@ ChangeMoney Money
as
Set Nocount ON
Declare @ String1 char (20)
Declare @ String2 char (30)
Declare @ String4 Varchar (100)
Declare @ String3 Varchar (100) - from the original A value out of the value of
Declare @ i int - cycle variables
Declare @ J Int - A value of 100 multiplied by the length of the string
Declare @ Ch1 Varchar (100) - the number of Chinese reading
Declare @ Ch2 Varchar (100) - the number of Chinese characters reading bit
Declare @ Zero Int - used to calculate a number of consecutive zero
Declare @ ReturnValue VarChar (100)

Select @ ReturnValue =''
Select @ String1 = 'zero one II III IV Jiu Wu Lu Qi split'
Select @ String2 = 'Found billion million thousand hundred thousand thousand million Bai Bai-up ten-dollar sub-angle'

Select @ String4 = Cast (@ ChangeMoney * 100 as int)

select @ J = len (cast ((@ ChangeMoney * 100) as int))

Select @ String2 = Right (@ String2, @ J)

Select @ i = 1

while @ i <= @ j Begin

Select @ String3 = Substring (@ String4, @ i, 1)

if @ String3 <>'0 'Begin

Select @ Ch1 = Substring (@ String1, Cast (@ String3 as Int) + 1, 1)
Select @ Ch2 = Substring (@ String2, @ i, 1)
Select @ Zero = 0 - that non-zero-based
end
else Begin
If (@ Zero = 0) Or (@ i = @ J - 9) Or (@ i = @ J - 5) Or (@ i = @ J - 1)
Select @ Ch1 = 'zero'
Else
Select @ Ch1 =''

Select @ Zero = @ Zero + 1 - that is 0-based

- If the conversion value needs to be expanded, then I need to change the value of the following expression.
Select Ch2 =''

If @ i = @ J - 10 Begin
Select @ Ch2 = 'million'
Select @ Zero = 0
end

If @ i = @ J - 6 Begin
Select @ Ch2 = 'million'
Select @ Zero = 0
end

if @ i = @ J - 2 Begin
Select @ Ch2 = 'element'
Select @ Zero = 0
end

If @ i = @ J
Select @ Ch2 = 'full'

end

Select @ ReturnValue = @ ReturnValue + @ Ch1 + @ Ch2

select @ i = @ i +1
end

- Finally, remove the excess zero
If CharIndex ( 'thousand thousand', @ ReturnValue) <> 0
Select @ ReturnValue = Replace (@ ReturnValue, 'thousand thousand', 'thousand')

If CharIndex ( 'Bai Bai', @ ReturnValue) <> 0
Select @ ReturnValue = Replace (@ ReturnValue, 'Bai Bai', 'Bai')

If CharIndex ( 'zero', @ ReturnValue) <> 0
Select @ ReturnValue = Replace (@ ReturnValue, 'zero', 'million')

If CharIndex ( 'zero-million', @ ReturnValue) <> 0
Select @ ReturnValue = Replace (@ ReturnValue, 'zero-million', 'million')

If CharIndex ( 'zero-billion', @ ReturnValue) <> 0
Select @ ReturnValue = Replace (@ ReturnValue, 'zero-billion', 'million')

If CharIndex ( 'zero the whole', @ ReturnValue) <> 0
Select @ ReturnValue = Replace (@ ReturnValue, 'zero the whole', 'whole')

If CharIndex ( 'zero-Bai', @ ReturnValue) <> 0
Select @ ReturnValue = Replace (@ ReturnValue, 'zero-Bai', 'zero')

If CharIndex ( 'zero-NT', @ ReturnValue) <> 0
Select @ ReturnValue = Replace (@ ReturnValue, 'zero-NT', 'zero')

If CharIndex ( 'Yuan Yuan', @ ReturnValue) <> 0
Select @ ReturnValue = Replace (@ ReturnValue, 'Yuan Yuan', 'million')

Select @ ReturnValue
GO


ASP Database Related Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.