Hi.
I want to know how it is possible to write your own function "UDF" in MySQL? and how use that UDF in MySQL?
tanha -2 Posting Whiz in Training
Recommended Answers
Jump to Post— peter_budo 2,532Something like this?
Jump to Post— tesuji 135hi,
MySQL does not support user defined functions (UDF) in the sense of standard SQL, which, for example, allow such a declaration in its own PSM language:create function avgg(*) returns float ap float select avg(price) from goods into ap return ap -- usage select id from …
Jump to Post— tesuji 135well tanha,
though i ve written UDFs for Sybase Databases a good many times, it s rather time-consuming doing that within MySQL. You may have a look at
to get an impression of the hard work to be done for it (as opposed to …
Jump to Post— tesuji 135Here is an UDF example which runs on SQL Anywhere 9:
CREATE FUNCTION upperFirstChar(IN isc VARCHAR(1000)) RETURNS VARCHAR(1000) /* Usage: select upperFirstChar('hello!') AS 'Capitalized 1st Character'; Result: Capitalized 1st Character ------------------------- Hello! */ BEGIN DECLARE rtc VARCHAR(1000); SELECT UPPER(SUBSTRING(isc, 1, 1)) + LOWER(SUBSTRING(isc, 2, LENGTH(isc)-1)) INTO rtc; …
Jump to Post— tesuji 135Hi tanha,
the given UDF should only be an example on how to program UDF using SQL Standard features. Since SQL 2003 (not 1999) there are UDFs defined, and they can be created with a rather new procedural language called PSM (Persistent Storage Moduls now part of SQL Standard, somehow …
All 17 Replies
tanha -2 Posting Whiz in Training
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster
tesuji 135 Master Poster
tanha -2 Posting Whiz in Training
tesuji 135 Master Poster
tesuji 135 Master Poster
tanha -2 Posting Whiz in Training
tanha -2 Posting Whiz in Training
tesuji 135 Master Poster
tanha -2 Posting Whiz in Training
tanha -2 Posting Whiz in Training
tanha -2 Posting Whiz in Training
tanha -2 Posting Whiz in Training
tanha -2 Posting Whiz in Training
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster
tesuji 135 Master Poster
tanha -2 Posting Whiz in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.