I have function which will return mi home or away if the p_search_string is same as those fields.
FUNCTION SEARACH_FOR_GAMES ( p_search_string in varchar2 )
return weak_cur
IS
SEARCH_FIXID WEAK_CUR;
BEGIN
OPEN SEARCH_FIXID FOR
select HOME,AWAY,COMP_NAME, M_TIME from SOCCER s
where s.HOME LIKE (:p_search_string) or s.AWAY LIKE (:p_search_string)
union all
select HOME,AWAY,LISTS,M_TIME from BASKETBALL b
where b.HOME LIKE (:p_search_string) or b.AWAY LIKE (:p_search_string)
union all
select HOME,AWAY,COMP,M_TIME from HANDBALL h
where h.HOME LIKE (:p_search_string) or h.AWAY LIKE (:p_search_string)
union all
select HOME,AWAY,LISTS,M_TIME from ICE_HOCKEY i
where i.HOME LIKE (:p_search_string) or i.AWAY LIKE (:p_search_string)
union all
select HOME,AWAY,COMP,M_TIME from TENISt
where t.HOME LIKE (:p_search_string) or t.AWAY LIKE (:p_search_string)
union all
select HOME,AWAY,LISTS,M_TIME from VOLLEYBALL v
where v.HOME LIKE (:p_search_string) or v.AWAY LIKE (:p_search_string);
RETURN SEARCH_FIXID;
END SEARACH_FOR_GAMES;
This works fine, but i m wondering is there a "nicer" way to write down these selects ?
Thanks
game_schedulesand another tablesportfor soccer, tennis etc with an idsport_idwhich is referenced by a foreign key ingame_schedules. You may then join these 2 tables in a single select(without multiple union alls) for your cursor.