A bit of a guess as I don't know what kind of output you want, but maybe this:
create or replace procedure p_ts_collisions_search
( p_col_mrn obiee_ts_collision_fact_vw.collision_master_record_number%type
, p_township obiee_ts_collision_fact_vw.township%type
, p_county obiee_ts_collision_fact_vw.county%type )
as
rc sys_refcursor;
begin
open rc for
select collision_master_record_number
, city
, road_name
from obiee_ts_collision_fact_vw
where collision_master_record_number = p_col_mrn
and township = p_township
and county = p_county;
dbms_sql.return_result(rc);
end;
Note that I have prefixed my parameters with p_
to differentiate them from the database columns, because and township = township
doesn't achieve much. (An alternative would be to label them with the procedure name, e.g. p_ts_collisions_search.township
.)
Dummy data:
create view obiee_ts_collision_fact_vw
as
select 1 as collision_master_record_number
, 'London' as city
, 'Bond Street' as road_name
, 'West End' as township
, 'Lalaland' as county
from dual;
Demo in SQL*Plus:
SQL> exec p_ts_collisions_search(1, 'West End', 'Lalaland');
PL/SQL procedure successfully completed.
ResultSet #1
COLLISION_MASTER_RECORD_NUMBER CITY ROAD_NAME
------------------------------ ------ -----------
1 London Bond Street
However, it won't work everywhere, as the client needs to be able to process implicit results:
SQL> call p_ts_collisions_search(1, 'West End', 'Lalaland');
call p_ts_collisions_search(1, 'West End', 'Lalaland')
*
ERROR at line 1:
ORA-29478: Implicit result cannot be returned through this statement.
ORA-06512: at "SYS.DBMS_SQL", line 2785
ORA-06512: at "SYS.DBMS_SQL", line 2779
ORA-06512: at "WILLIAM.P_TS_COLLISIONS_SEARCH", line 17
Alternatively, you could return the result set explicitly via an out
parameter:
create or replace procedure p_ts_collisions_search
( p_col_mrn obiee_ts_collision_fact_vw.collision_master_record_number%type
, p_township obiee_ts_collision_fact_vw.township%type
, p_county obiee_ts_collision_fact_vw.county%type
, p_results out sys_refcursor )
as
begin
open p_results for
select collision_master_record_number
, city
, road_name
from obiee_ts_collision_fact_vw
where collision_master_record_number = p_col_mrn
and township = p_township
and county = p_county;
end;
Demo:
SQL> var results refcursor
SQL> set autoprint on
SQL> exec p_ts_collisions_search(1, 'West End', 'Lalaland', :results);
PL/SQL procedure successfully completed.
COLLISION_MASTER_RECORD_NUMBER CITY ROAD_NAME
------------------------------ ------ -----------
1 London Bond Street