View Single Post

   
  #6 (permalink)  
Old 02-28-2008, 11:28 AM
Martijn Tonies
 
Posts: n/a
Default Re: SELECT has different effect in a view

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


Reply With Quote