I have oracle proc on which I am passing data to filter the records. The data passed is election_id and this election_id can be anywhere from 10 to 20000 at a time. The varchar datatype is not sufficient so management have decided to go for Global temp table. The DBA has asked for a script to create a GTT, but the issue is I do not know what should I place in GTT. Based on my proc, do I put whole table in GTT or some specific column or do I place the election_id. Also the election_id is used in other procs as well so do I create multiple GTT ? I am kind a lost right now please help me to tackel this issue. Help will be highly appreciated.
create or replace PROCEDURE County_election(
election_id IN varchar2, //this data is too large so we creating GTT
date_occured IN Date,
state IN varchar2,
country varchar2
)
with election_id_list as(
parsing comma separated election_id and selecting from dual
)
regular query
SELECT s.state, s.country, t.mayor, m.name, COUNT (DISTINCT s.seat) seat_won
FROM COUNTY s
JOIN Area t ON t.e_id = s.e_id
JOIN Memebers m on m.mem_id=t.mem_id and mem_id IN (sub query)
where s.election_id in (select election_id from election_id_list ) //large data is used in where clause to filter the data