Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
mdanwerali
Starting Member
30 Posts |
Posted - 2002-11-13 : 00:55:50
|
| Hii have this code written in java now i am trying to convert the same code to sql server function. but i am getting problems at ARRAYS. can u please tell me how to write the following code in sql server ----create or replace java source named "numinwords" asimport java.util.*;public class NumInWords{public static String ToWords(int xNumber){String UW[]={"", "One ", "Two ", "Three ", "Four ", "Five ", "Six ", "Seven ","Eight ", "Nine "};String TW[]={"", "Ten ", "Twenty ", "Thirty ", "Fourty ", "Fifty ", "Sixty ","Seventy ", "Eighty ", "Ninety "};String WW[]={"Ten ", "Eleven ", "Twelwe ", "Thirteen ", "Fourteen ", "Fifteen", "Sixteen ", "Seventeen ", "Eighteen ", "Nineteen "};int DW[]=new int[9];String z="";int xCount=0;if (xNumber==0)z="Zero rupees only";else{while(xNumber>0){DW[xCount]=xNumber%10;xNumber=xNumber/10;xCount++;}if (DW[4] == 1)z = z + WW[DW[3]] + " Thousand ";else if (DW[4] > 1 )z = z + TW[DW[4]] + UW[DW[3]] + " Thousand ";else if (DW[4] == 0 ){if (DW[3] > 0 )z = z + UW[DW[3]] + " Thousand ";}if (DW[2] > 0)z = z + UW[DW[2]] + " Hundred ";if (DW[1] == 1)z = z + WW[DW[0]];else if (DW[1] > 1)z = z + TW[DW[1]] + UW[DW[0]];else if (DW[1] == 0 ){if (DW[0] >= 1)z = z + UW[DW[0]];}if (z!="")z = z + " rupees only ";}return z;}};----Thanks in advanceMd Anwer Ali |
|
|
mr_mist
Grunnio
1870 Posts |
Posted - 2002-11-13 : 03:26:54
|
| This is very similar in concept to the Roman Numerals thread which was done recentlyhttp://www.sqlteam.com/Forums/topic.asp?TOPIC_ID=21405You would essentially need that bit of code altered to use words instead of the roman letters, I think. |
 |
|
|
|
|
|
|
|