The website provides the remove_constants function to check the SQL running status in the shared pool. The solution is to change the query condition value to a common tag, for example, select * fr.
The website provides the remove_constants function to check the SQL running status in the shared pool. The solution is to change the query condition value to a common tag, for example, select * fr.
The website provides the remove_constants function to check the SQL running status in the shared pool. The solution is to change the query condition value to a common tag, for example: replace select * from t where object_id = 1 with select * from t where object_id = @.
SQL> drop table find_no_bind purge;
SQL> create table t as select * from dba_objects where 1 = 2;
-- Create a record table
SQL> create table find_no_bind as select SQL _text from v $ sqlarea;
SQL> alter table find_no_bind add SQL _text_copy varchar2 (1000 );
-- Create a replacement function and replace the placeholder @
Create or replace function
SQL> remove_constants (p_query in varchar2) return varchar2
As
Rochelle query long;
Rochelle char varchar2 (1 );
Rochelle in_quotes boolean default FALSE;
Begin
For I in 1 .. length (p_query)
Loop
L_char: = substr (p_query, I, 1 );
If (l_char = ''' and l_in_quotes)
Then
Rochelle in_quotes: = FALSE;
Elsif (l_char = ''' and NOT l_in_quotes)
Then
Rochelle in_quotes: = TRUE;
L_query: = l_query | '''#';
End if;
If (NOT l_in_quotes) then
L_query: = l_query | l_char;
End if;
End loop;
Rochelle query: = translate (Rochelle query, '123 ','@@@@@@@@@@');
For I in 0 .. 8 loop
Rochelle query: = replace (l_query, lpad ('@', 10-i ,'@'),'@');
Rochelle query: = replace (l_query, lpad ('', 10-i ,''),'');
End loop;
Return upper (l_query );
End;
/
-- Clear the share pool first. The formal environment cannot do this.
SQL> alter system flush shared_pool;
SQL> begin
For I in 1 .. 1000 loop
Execute immediate 'select * from t where OBJECT_ID = '| I;
End loop;
End;
/
SQL> update find_no_bind set SQL _text_copy = remove_constants (SQL _text );
SQL> commit;
SQL> col SQL _text_copy format a40
SQL> select SQL _text_copy, count (*)
2 from find_no_bind
3 group by SQL _text_copy
4 having count (*)> 10;
SQL _TEXT_COPY COUNT (*)
--------------------------------------------------
SELECT * from t where OBJECT_ID = @ 1000