求助!编写mysql函数

如何在myql中编写一个函数那?它的基本的语法是什么样的?
那为高手教我!\
例如:
传进两个参数,.返回一个字符型的数!

谢谢!!

Taxonomy upgrade extras:

drop procedure if EXISTS p_calc_item_last_step//
create PROCEDURE p_calc_item_last_step(in in_from_table_name varchar(255) , out result varchar(255) )
BEGIN
DECLARE start_time datetime;
DECLARE end_time datetime;
DECLARE temp_types INTEGER(4);

select types into temp_types from analysis_configs where from_table_name = in_from_table_name;
select DATE_FORMAT(now(),"%Y-%m-%d %H:00:00") into end_time;
if temp_types<11 then
set start_time = DATE_FORMAT(SUBDATE(now(), INTERVAL 1 hour), "%Y-%m-%d %H:00:00");
else
set start_time = DATE_FORMAT(SUBDATE(now(), INTERVAL 1 day), "%Y-%m-%d 00:00:00");
set end_time = DATE_FORMAT(end_time, "%Y-%m-%d 00:00:00");
end if;

select start_time, end_time;

result = "successful";
end;

如果用C程序来调用该存储过程,如何获得result的值??请指教····