MySQL Forums
Forum List  »  German

Function & Zuweisung eines Select Ergebnisses an einer Variable
Posted by: Dirk Soetebeer
Date: April 05, 2014 01:53PM

Hallo,

beim Erstellen der Function, in der eine Variable ein Wert von einem Select-Befehl zugewiesen werden soll, wird immer der Fehler >>>> Error Code: 1415. Not allowed to return a result set from a function <<<< angezeigt:

DROP function if exists checkEbene;
delimiter $$
create function checkEbene(id_Parameter int)
returns integer
language sql
begin
set @iTiefe = 0;
set @iid = id_Parameter;
checks: loop
if exists (select 1 from tab_Test where id_Feld = @iid) then
set @iTiefe = @iTiefe + 1;
select @iid:=id_Feld1 from tab_Test where id = @iid limit 1;
else
leave checks;
end if;
end loop;
return iTiefe;
end;
$$
delimiter ;

----------------------------

Die folgende Befehlszeile wird nicht akzeptiert:

select @iid:=id_Feld1 from tab_Test where id = @iid limit 1;

Kann mir jemand mitteilen, wie man innerhalb der Function eine Variable einen Wert aus einem Select-Befehl zuweisen kann?

Vielen Dank im voraus.

Options: ReplyQuote


Subject
Views
Written By
Posted
Function & Zuweisung eines Select Ergebnisses an einer Variable
1971
April 05, 2014 01:53PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.