This is a discussion on MySql Random string within the Database Support forums, part of the Web Development category; Hi buddies, Is there any built in function available in mysql for generating random string. ? There are few functions like ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Hi buddies, Is there any built in function available in mysql for generating random string. ? There are few functions like MD5(), SHA() may be used for this purpose, but the throughput of these functions are with the combination of numeric and alphabets. what i need is that i want the random string in alphabets with upper and lower case combination.
__________________ Keep smiling... Last edited by priyan : 07-13-2007 at 01:39 AM. |
| Sponsored Links |
| |||
| Hi Priyan, As per my idea, only possibility to create your own Stored Function / Stored Procedure for Returning random string in alphabets with upper and lower case combination. Me too wait for any other reply.
__________________ -Murali.. |
| |||
| Hi murali, I got it thru stored function... here it's .. but what i m looking is that built-in function for this.. We hope that this utility may be available in future mysql releases. /* ************************************************* Purpose : To get the random string (only alphabets) Input : Length of the randon string required (pmStringlength) ************************************************** */ CREATE FUNCTION get_random_string(pmStringlength INTEGER) RETURNS VARCHAR(100) DETERMINISTIC BEGIN DECLARE vString_length INTEGER; DECLARE vReturn_string VARCHAR(100) DEFAULT ''; DECLARE vTemp1 INTEGER; DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN RETURN -99; END; SET vString_length = pmStringlength; -- Loop will execute to the no of characters given in input WHILE vString_length > 0 DO -- Getting a random number between 65 and 122 SET vTemp1 = FLOOR( 65 + (RAND() * 57)); IF (vTemp1 >= 90 AND vTemp1 <= 96) THEN SET vTemp1 = vTemp1 + 10; END IF; -- Changing the random number into character and concatenate SET vReturn_string = CONCAT(vReturn_string,CHAR(vTemp1)); SET vString_length = vString_length - 1; END WHILE; -- Return result RETURN vReturn_string; END; /**************************************/ SELECT get_random_string(10); Result : eOrcWKhxko SELECT get_random_string(105) Result : qSDTgeqspfwToBkcoNmIdmbjyQhgqNegiJPoRDUfLCakCypJTK uCeKiHEwbCdEDGUdJhCgPSmuPdSibmLdfcirivjASeKydOtmKa
__________________ Keep smiling... |
| |||
| Yes. At Present in MYSQL 5.0 the only possiblity is creating our owned defined objects for generating the Random String as per ur point[Only with Characters]. But we expect this and more features in the forthcoming MYSQL Versions.
__________________ -Murali.. |
![]() |
| Thread Tools | |
| Display Modes | |
| |
LinkBacks (?)
LinkBack to this Thread: http://www.discussweb.com/database-support/1632-mysql-random-string.html | |||
| Posted By | For | Type | Date |
| MySql Random string | Web Hosting | This thread | Refback | 03-06-2008 11:23 AM |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Compare a string with String Array. | oxygen | C# Programming | 5 | 12-28-2007 11:18 PM |
| What is diffrenece between string.compare and string.compareordinal | shaalini | ASP and ASP.NET Programming | 3 | 12-28-2007 10:46 PM |
| To get random number in mysql | Murali | Database Support | 7 | 11-05-2007 11:34 PM |
| How to split a string by using a string usually in the c# dotnet... | Archer | C# Programming | 1 | 07-25-2007 03:26 AM |
| How to set Random image selector in asp.net ? | kingmaker | ASP and ASP.NET Programming | 1 | 07-23-2007 06:31 AM |