Skip to content

Instantly share code, notes, and snippets.

@oraculix
Last active January 25, 2023 12:57
Show Gist options
  • Save oraculix/9f4d58ea0c042aec1dc65e516901f7e1 to your computer and use it in GitHub Desktop.
Save oraculix/9f4d58ea0c042aec1dc65e516901f7e1 to your computer and use it in GitHub Desktop.
Regular expression search in Oracle PL/SQL source code
-- Find first occurence of NEXTVAL case-insensitive and deliver the line of occurrence and the lines around it.
WITH found AS (
SELECT owner, name, type, line FROM all_source
WHERE owner = 'GSMADMIN_INTERNAL'
AND regexp_instr(text, 'NEXTVAL',1,1,0,'i') > 0
)
SELECT a.*
FROM all_source a, found
WHERE a.owner = found.owner
AND a.name = found.name
AND a.type = found.type
AND a.line BETWEEN found.line-1 AND found.line+1
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment