Patrick,
> CREATE FUNCTION super_cat (id varchar(20)) RETURNS varchar(20)
> begin
> declare x,y varchar(20);
> select supervisor into x from people where userid = id;
> if x is null then
> return null;
> else
> select category into y from people where userid = x;
> return y;
> end if;
> end
You might want to take a loko at that first part there --
if there's no resultset, what does X become? If you initialize X with
something, eg:
declare x, y varchar(20);
x = 'test';
select supervisor into x from people where userid = id;
is X NULL or 'test'?
I'm wondering, cause I don't think the SELECT will put anything
into X if there's no resultset.
--
Martijn Tonies
Database Workbench - development tool for MySQL, and more!
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com