Home > database >  There are big? Help the essentially function modified into mysql function?
There are big? Help the essentially function modified into mysql function?

Time:09-17

ALTER the function [dbo] [hex] (@ cardno int)
Returns a varchar (100)
As
The begin
Declare @ temp_mod int
Declare @ I int
Declare @ result varchar (100)
Declare @ temp_x int
Declare @ result_values int
Declare @ int j
Declare @ tmpresult varchar (100)

The set @ result='
The set @ I=1
The set @ temp_x=0
The set @ j=0;

Declare @ tmpint bigint

The set @ tmpint=@ cardno
If @ cardno <0
The begin
The set @ tmpint=~ (- @ cardno) + 1
The set @ tmpint=@ tmpint & 0 x0ffffffff
End

While @ tmpint!=0
The begin
The set @ temp_mod=@ % tmpint 16
The set @ tmpint=@ tmpint/16

The set @ result=(case @ temp_mod when 10 then 'A'
Then the when 11 'B'
12 then the when 'C'
13 then the when 'D'
The when 14 then 'E'
15 then the when 'F'
The when 16 then 'G'
17 then the when 'H'
18 then the when the 'I' else ltrim (STR) (@ temp_mod) end) + @ result
Select @ j=@ j + 1

End
If len (@ result)> 8
The begin
Select @ tmpresult=Right (@ result, 8)
End
The else
The begin
Select @ tmpresult=@ result
End
If len (@ tmpresult) 8
If len (@ tmpresult)=7
Select @ tmpresult='0' + @ tmpresult
Else if len (@ tmpresult)=6
Select @ tmpresult='00' + @ tmpresult
End
Select @ result=the substring (@ tmpresult, 7, 2) + the substring (@ tmpresult, 5, 2) + the substring (@ tmpresult, 3, 2) + the substring (@ tmpresult, 1, 2)
Return cast (@ result as varchar)
end
  • Related