pull string of words out of a file

I have an oracle trace file and want to pull the table name out of the file

FROM "table_name" is how it appears in the file.

I don't know if sed can do this I can't get awk to do this because the file wraps the text.
LVL 1
bkreynolds48Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sdstuberCommented:
can you post your trace file?  or at least a snippet you're trying to parse?
bkreynolds48Author Commented:
Select BEG_VERSION, EXT_VERSION, FIRST_DATE, FIRST_USER, IND_CHANGE,
 INT_VERSION, I_PROJECT, LAST_DATE, LAST_USER, PROJECT_CODE, PROJECT_NAME,
 PRV_VERSION, V_LAST_DATE
FROM
 SNP_PROJECT where I_PROJECT = :1

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        9      0.00       0.00          0          0          0           0
Execute    823      0.02       0.02          0          0          0           0
Fetch      823      0.05       0.05          0       1646          0         823
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total     1655      0.08       0.08          0       1646          0         823

Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: ALL_ROWS
Parsing user id: 100

Rows     Row Source Operation
-------  ---------------------------------------------------
 1  TABLE ACCESS BY INDEX ROWID SNP_PROJECT (cr=2 pr=0 pw=0 time=0 us cost=1 size=108 card=1)
 1   INDEX UNIQUE SCAN PK_PROJECT (cr=1 pr=0 pw=0 time=0 us cost=0 size=0 card
bkreynolds48Author Commented:
or it appears in the unformated file like....


Select BEG_VERSION, EXT_VERSION, FIRST_DATE, FIRST_USER, IND_CHANGE, INT_VERSION, I_PROJECT, LAST_DATE, LAST_USER, PROJECT_CODE, PROJECT_NAME, PRV_VERSION, V_LAST_DATE FROM SNP_PROJECT where I_PROJECT = :1

Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

sdstuberCommented:
which do you want to parse?

the trace file?
or the tkprof output?
bkreynolds48Author Commented:
the unformatted trace file

Select BEG_VERSION, EXT_VERSION, FIRST_DATE, FIRST_USER, IND_CHANGE, INT_VERSION, I_PROJECT, LAST_DATE, LAST_USER, PROJECT_CODE, PROJECT_NAME, PRV_VERSION, V_LAST_DATE FROM SNP_PROJECT where I_PROJECT = :1

sdstuberCommented:
more robust parsing is outside the province of awk,  but this does a fair job for simple sql statements


awk 'BEGIN {foundparse=0}
/^PARSING IN CURSOR/ {foundparse=1}
/^END OF STMT/ {
   foundparse=0
   foundfrom=0
}
/[Ff][Rr][Oo][Mm]/{if (foundparse==1) foundfrom=1}
{
   if (foundfrom==1) {
      fromposition = match ($0, "[Ff][Rr][Oo][Mm]")
	  if (fromposition == 0) search = $0
      else search = substr($0,fromposition+4)
      wordcnt = split(search, words, "[ ,\t]+")
	  foundwhere=0
      for (i =1; i <= wordcnt && !foundwhere; i++) {
	     if (match(words[i],"[Ww][Hh][Ee][Rr][Ee]") > 0) foundwhere=1
	     else print words[i]
      }
   }
}' your_trace_file

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bkreynolds48Author Commented:
so how do I run this and capture the output?
sdstuberCommented:
you run it on the command line exactly as presented

only change will be you use your own trace file's name where I have "your_trace_file"

bkreynolds48Author Commented:
thanks much
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.