How will the following coding be changed if I'm using it in MySQL? Please someone help me...
SQL Server Code - create function dbo.iso6346_char_to_number
-
(
-
@char char
-
)
-
returns int
-
as
-
begin
-
return
-
case upper(@char)
-
when '0' then 0
-
when '1' then 1
-
when '2' then 2
-
when '3' then 3
-
when '4' then 4
-
when '5' then 5
-
when '6' then 6
-
when '7' then 7
-
when '8' then 8
-
when '9' then 9
-
when 'A' then 10
-
when 'B' then 12
-
when 'C' then 13
-
when 'D' then 14
-
when 'E' then 15
-
when 'F' then 16
-
when 'G' then 17
-
when 'H' then 18
-
when 'I' then 19
-
when 'J' then 20
-
when 'K' then 21
-
when 'L' then 23
-
when 'M' then 24
-
when 'N' then 25
-
when 'O' then 26
-
when 'P' then 27
-
when 'Q' then 28
-
when 'R' then 29
-
when 'S' then 30
-
when 'T' then 31
-
when 'U' then 32
-
when 'V' then 34
-
when 'W' then 35
-
when 'X' then 36
-
when 'Y' then 37
-
when 'Z' then 38
-
end
-
end
-
-
-
create function dbo.iso6346_check_digit
-
(
-
@string char(10)
-
)
-
returns char
-
as
-
begin
-
return (dbo.iso6346_char_to_number(substring(@string,1,1) )*1
-
+dbo.iso6346_char_to_number(substring(@string,2,1) )*2
-
+dbo.iso6346_char_to_number(substring(@string,3,1) )*4
-
+dbo.iso6346_char_to_number(substring(@string,4,1) )*8
-
+dbo.iso6346_char_to_number(substring(@string,5,1) )*16
-
+dbo.iso6346_char_to_number(substring(@string,6,1) )*32
-
+dbo.iso6346_char_to_number(substring(@string,7,1) )*64
-
+dbo.iso6346_char_to_number(substring(@string,8,1) )*128
-
+dbo.iso6346_char_to_number(substring(@string,9,1) )*256
-
+dbo.iso6346_char_to_number(substring(@string,10,1 ))*512)%11
-
end
0 1798 Sign in to post your reply or Sign up for a free account.
Similar topics
by: Detlef Jockheck |
last post by:
Hi,
I would like to check if a string contains a valid date format
(Format: "dd.mm.yyyy") or not.
What is the best way to do this. regexp? At the moment it would be
sufficient to check for...
|
by: anaxamandr |
last post by:
Hi.
I have a long loop in ASP that performs a rather lengthy calculation. I would love for my users to be able to stop that calculation, if they so choose, mid way through the process.
I attempted...
|
by: Ivan |
last post by:
Hi,
how to filter out non-digit chars when user writes text to System.Windows.Forms.TextBox?
Thanks,
Iavmn
|
by: pinkfloydhomer |
last post by:
How do I check if a string contains (can be converted to) an int? I
want to do one thing if I am parsing and integer, and another if not.
/David
|
by: kathy |
last post by:
I want to know what is the easy way to check if a string is a number or
not? the number can be int, float, double, scientific,...
what is the easy way for only interger?
|
by: linq936 |
last post by:
I have some algorithm dealing with unsigned int calculation a lot, I am
trying to add some check for overflow. The initial thinking was very
easy, just do something like this,
int...
|
by: balakrishnan.dinesh |
last post by:
hi frnds,
Im having two 20digit numbers, But while comparing those it
is giiving wrong ouput in javascript.
for example here is my code,
my secanrio is ,
~ If first 20 digit number is...
|
by: beach.dk |
last post by:
Hi,
I'm trying to implement a simple hash algorith called rs_hash in
javascript,
but I cannot get a correct result.
In c the code looks like this:
|
by: Shirsoft |
last post by:
I have a 32 bit intel and 64 bit AMD machine. There is a rounding
error in the 8th digit. Unfortunately because of the algorithm we use,
the errors percolate into higher digits.
C++ code is...
|
by: upyzl |
last post by:
#include <stdio.h>
#define digit 21
int main()
{
int a, b, max;
int i = 0;
int j = 0;
int x = { 0 };
int y = { 0 };
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |