sql >> Base de Datos >  >> RDS >> Oracle

sqlplus - usando una variable de vinculación en la cláusula IN

Almacenaría el other_table.id está en una tabla PL/SQL y haga referencia a esa tabla en la consulta posterior:

type t_id_table is table OF other_table.id%type index by binary_integer;
v_table t_id_table;

-- fill the table
select id
bulk collect into v_table
from other_table 
where abc in ('&val1','&val2','&val3');     

-- then at a later stage...    

select *
from some_table st
,    table(cast(v_table AS t_id_table)) idt
where st.id = idt.id;