views:

16

answers:

1

I have a user defined function.

In that function I declared a variable of type datetime.

I am assigning the result of a query into this variable. And I am returning this assigned value. It looks like

delimiter$$
drop function if exists getQEDate$$
create function getQEDate() returns datetime
begin

  declare qedate datetime;
  select date into qedate from qenddates where ....;

  return qedate;
end$$
delimiter ;

When accessing this function I am getting an exception like "returns more than a row...". So I am thinking this error occurred while returning the result. That means the variable qedate can hold more than one row.

Is the above analysis makes sense ?

A: 

It's probably that your query is returning more than 1 row and it can't store that into a variable. If you're only expecting 1 row you should check your where clause or add LIMIT 1 to the end of the query in the function.

I'm guessing since I can't see your data or your where clause :)

Cfreak
Sorry I am not asking for the solution. I am just confirming that a variable can hold more than one row or not.
Multiplexer
Then the answer is no. It cannot
Cfreak