analytics never cease to amaze me :)
this gets some false positives, but the concept is there -- you can refine it as needed:
ask_tom@ASKUS> column line format 9999
ask_tom@ASKUS> column name format a15
ask_tom@ASKUS> column text format a90
ask_tom@ASKUS> column marker format a6
ask_tom@ASKUS> set linesize 200
ask_tom@ASKUS>
ask_tom@ASKUS> select max_rn, name, line, text
2 from (
3 select name, line, replace( text, chr(10), ' ' ) text, max_rn,
4 case when first_value(upper(text)) over (partition by name, max_rn order by line) like '%UPDATE %' then 'X' end x
5 from (
6 select name, line, text, rn,
7 max(rn) over (partition by name order by line) max_rn
8 from (
9 select name, text, line,
10 case when upper(text) like '%UPDATE %' OR
11 trim( rtrim(lag(text) over (partition by name order by line),chr(10)) ) like '%;'
12 then row_number() over (partition by name order by line) end rn
13 from user_source
14 where type in ( 'PACKAGE BODY', 'PROCEDURE', 'FUNCTION' )
15 order by name, line
16 )
17 )
18 )
19 where x = 'X'
20 /
MAX_RN NAME LINE TEXT
---------- --------------- ----- ------------------------------------------------------------------------------------------
41 ASK_TOM_PKG 41 <br>Please update your bookmarks...
41 ASK_TOM_PKG 42 </BODY>
41 ASK_TOM_PKG 43 </HTML>
41 ASK_TOM_PKG 44 ');
4 P 4 update t set x = x;
245 WWC_ASK_API 245 update wwc_ask_application_controls$
245 WWC_ASK_API 246 set enabled = 'Y'
245 WWC_ASK_API 247 where application_code = 'NONEW';
337 WWC_ASK_API 337 update wwc_ask_submitted_questions$
337 WWC_ASK_API 338 set email = p_email,
337 WWC_ASK_API 339 fname = p_fname,
337 WWC_ASK_API 340 lname = p_lname,
337 WWC_ASK_API 341 location = p_location,
337 WWC_ASK_API 342 title = p_job_title,
337 WWC_ASK_API 343 org = p_org,
337 WWC_ASK_API 344 category = p_category,
337 WWC_ASK_API 345 version = p_version,
337 WWC_ASK_API 346 years_exp = p_years,
337 WWC_ASK_API 347 subject = p_subject,
337 WWC_ASK_API 348 remote_addr = l_remote_addr,
337 WWC_ASK_API 349 http_user_agent = l_http_user_agent,
337 WWC_ASK_API 350 http_referer = l_http_referer,
337 WWC_ASK_API 351 status = decode( status, g_NEWNEVERREAD, g_NEWNEVERREAD, g_READAWAITINGINFO, g_
READMOREINFOSUPPLIED ),
337 WWC_ASK_API 352 question = empty_clob()
337 WWC_ASK_API 353 where id = p_id
337 WWC_ASK_API 354 and status in (g_NEWNEVERREAD, g_READAWAITINGINFO )
337 WWC_ASK_API 355 returning question into l_question;
and if we add a user defined aggregate:
</code>
http://asktom.oracle.com/pls/asktom/f?p=100:11:::::P11_QUESTION_ID:15637744429336 <code>
we can:
ask_tom@ASKUS> select name, up_date
2 from (
3 select max_rn, name, line,
4 stragg( trim(text) || ' ') over (partition by name, max_rn order by line) up_date,
5 last_value(line) over (partition by name, max_rn) last_line
6 from (
7 select name, line, replace( text, chr(10), ' ' ) text, max_rn,
8 case when first_value(upper(text)) over (partition by name, max_rn order by line) like '%UPDATE %' then 'X' end x
9 from (
10 select name, line, text, rn,
11 max(rn) over (partition by name order by line) max_rn
12 from (
13 select name, text, line,
14 case when upper(text) like '%UPDATE %' OR
15 trim( rtrim(lag(text) over (partition by name order by line),chr(10)) ) like '%;'
16 then row_number() over (partition by name order by line) end rn
17 from user_source
18 where type in ( 'PACKAGE BODY', 'PROCEDURE', 'FUNCTION' )
19 order by name, line
20 )
21 )
22 )
23 where x = 'X'
24 )
25 where line = last_line
26 /
NAME
---------------
UP_DATE
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ASK_TOM_PKG
<br>Please update your bookmarks... ,</BODY> ,</HTML> ,');
P
update t set x = x;
WWC_ASK_API
update wwc_ask_application_controls$ ,set enabled = 'Y' ,where application_code = 'NONEW';
WWC_ASK_API
update wwc_ask_submitted_questions$ ,set email = p_email, ,fname = p_fname, ,lname = p_lname, ,location = p_location, ,title = p_job_title, ,org = p_org, ,category = p_category, ,version = p_version,
,years_exp = p_years, ,subject = p_subject, ,remote_addr = l_remote_addr, ,http_user_agent = l_http_user_agent, ,http_referer = l_http_referer, ,status = decode( status, g_NEWNEVERREAD, g_NEWNEVERREAD
, g_READAWAITINGINFO, g_READMOREINFOSUPPLIED ), ,question = empty_clob() ,where id = p_id ,and status in (g_NEWNEVERREAD, g_READAWAITINGINFO ) ,returning question into l_question;
.....