-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsqlid.sql
More file actions
49 lines (34 loc) · 941 Bytes
/
sqlid.sql
File metadata and controls
49 lines (34 loc) · 941 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
--
-- Shows the text of an SQL statement if its sql_id is known.
--
set verify off
-- Old Version: Could not cope with statement longer the 4K...
--
-- select listagg(sql_text, '') within group (order by piece)
-- from v$sqltext_with_newlines
-- where sql_id = '&1';
declare
l varchar2(4000);
c char(1);
begin
for s in (select sql_text
from v$sqltext_with_newlines
where sql_id = '&1'
order by piece) loop
for i in 1 .. length(s.sql_text) loop
c := substr(s.sql_text, i, 1);
if c = chr(10) then
dbms_output.put_line(l);
l := '';
elsif length(l) > 3999 then
-- Adjust for width of terminal here.
dbms_output.put_line(l);
l := c;
else
l := l || c;
end if;
end loop;
end loop;
dbms_output.put_line(l);
end;
/