User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 374,616 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,277 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser:

UDF in MySQL

Join Date: Aug 2007
Posts: 141
Reputation: tanha is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
tanha tanha is offline Offline
Junior Poster

Re: UDF in MySQL

  #9  
May 11th, 2008
sir,
I can not create the below function in MySQL...
what I should I do to just create the below function in MySQL 5.0.41. could you just guide through that


Originally Posted by tesuji View Post
Here is an UDF example which runs on SQL Anywhere 9:
  1. CREATE FUNCTION upperFirstChar(IN isc VARCHAR(1000))
  2. RETURNS VARCHAR(1000)
  3. /* Usage:
  4.   select upperFirstChar('hello!') AS 'Capitalized 1st Character';
  5.   Result:
  6.   Capitalized 1st Character
  7.   -------------------------
  8.   Hello!
  9. */
  10. BEGIN
  11. DECLARE rtc VARCHAR(1000);
  12. SELECT UPPER(SUBSTRING(isc, 1, 1)) + LOWER(SUBSTRING(isc, 2,
  13. LENGTH(isc)-1)) INTO rtc;
  14. RETURN rtc;
  15. END;
I use select upper(substring(... to capitalize first char. You can also use this select within MySQL because all char functions are also available there.
Reply With Quote  
All times are GMT -4. The time now is 8:58 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC