drop PROCEDURE Mem_GetNextTrackgoCREATE PROCEDURE Mem_GetNextTrack (in in_listener_guid bigint(20) unsigned, in in_station_id int(11) unsigned)BEGIN if (in_listener_guid is not null) and (in_listener_guid > 0) and (in_station_id is not null) and (in_station_id > 0) then START TRANSACTION; set @IsNewStation = null; if not exists (select station_id from mem_radiostations where station_id=in_station_id limit 1) then if in_station_id < 1000000 then call Mem_CreateChannelByGenreId(in_station_id); set @IsNewStation = true; else select 0, null; end if; else set @IsNewStation = false; end if; if @IsNewStation is not null then //declare media_id int(11) unsigned default null; //declare sign_on_id int(11) unsigned default null; call Mem_GetNextTrackInternal(in_listener_guid, in_station_id, @IsNewStation, @media_id, @sign_on_id); select @media_id, @sign_on_id; end if; COMMIT; else select 1, null; end if;ENDGO