Home >Backend Development >PHP Tutorial >Stored procedure for converting amounts from Arabic numerals to Chinese_PHP tutorial

Stored procedure for converting amounts from Arabic numerals to Chinese_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:01:301128browse

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) --The value taken from the original A value
Declare @i int --Loop variable
Declare @J Int --The value of A multiplied by the string length of 100
Declare @Ch1 Varchar(100) --Chinese pronunciation of numbers
Declare @Ch2 Varchar(100) --Chinese pronunciation of digits
Declare @Zero Int --Used to calculate how many consecutive numbers there are Zero
Declare @ReturnValue VarChar(100)
Select @ReturnValue = ''
Select @String1 = 'Zero One Two Three Four Five Lands Seven'
Select @String2 = 'Ten Thousand Thousand Hundreds Hundreds of millions of cents'
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 --Indicates that the bit is not zero
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 --Indicates that the base is 0

--If the converted value needs to be expanded, then the value of the following expression I needs to be changed.
Select Ch2 = ''
If @i = @J - 10 Begin
Select @Ch2 = 'Billion'
Select @Zero = 0
end

If @ i = @J - 6 Begin

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631147.htmlTechArticleCreate 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...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn