Author Topic: Returning various parts of the same string  (Read 727 times)

Offline rhythmz

  • Full Member
  • ***
  • Join Date: Jul 2009
  • Posts: 41
  • Forum Citizenship: +0/-0
Returning various parts of the same string
« on: 15 Jun 2017 01:17:25 pm »
I am developing an audit report in which I want to obtain the folder path to a report. However, the best result set that I can get to is something similar to:

/content/folder[@name='Credit Group']/folder[@name='Account Management']/folder[@name='Loan Officer Portfolios']/report[@name='Credit Line Approvals']

I greatly desire to achieve an output like:

Credit Group/Account Management/Loan Officer Portfolios/Credit Line Approvals

However, I am literally  :-\ brain dead :-\ on how to accomplish this...SUBSTR comes to mind, however, the length of the string and occurrences of "']/folder[@name='" can vary according to the actual folder path. I am trying to determine those reports in my catalog that are NOT getting used regularly to archive....I can see 'last run date' but cannot determine the frequency of use with the current given RS parameters. BTW, I have no admin panel access.

Thank so much for any help provided,
Dennis

Offline Lynn

  • Statesman
  • ******
  • Join Date: Apr 2008
  • Posts: 2,610
  • Forum Citizenship: +335/-1
Re: Returning various parts of the same string
« Reply #1 on: 16 Jun 2017 01:51:04 am »
Yes, this is hideous. You should get something like this:

Credit Group > Account Management > Loan Officer Portfolios > Credit Line Approvals

Our audit database is SQL Server so this exact syntax may or may not work if you have a different database. Perhaps others have more elegant expressions to do the same.


Code: [Select]
replace (
replace (
replace (
replace (
replace (
replace (
replace (
case
  when position ( 'CAMID',  [Audit Physical].[COGIPF_RUNREPORT].[COGIPF_REPORTPATH] ) = 1
            and
            position ( 'My Folders',  [Audit Physical].[COGIPF_RUNREPORT].[COGIPF_REPORTPATH] ) > 0
      then
          [Audit Physical].[COGIPF_USERLOGON_SESSION].[COGIPF_USERNAME] + ' > My Folders'
  when position ( '/report[@name=',  [Audit Physical].[COGIPF_RUNREPORT].[COGIPF_REPORTPATH] ) > 0
      then
          substring ( [Audit Physical].[COGIPF_RUNREPORT].[COGIPF_REPORTPATH],
                  1,
                  position ( '/report[@name=',  [Audit Physical].[COGIPF_RUNREPORT].[COGIPF_REPORTPATH] )-1
           )
   when [Audit Physical].[COGIPF_RUNREPORT].[COGIPF_REPORTNAME] = 'adHocReport'
       then 'Unknown Location'
   else [Audit Physical].[COGIPF_RUNREPORT].[COGIPF_REPORTPATH]
 end
, '/content', '' )
, '/folder[@name=''', '' )
, '/package[@name=''', '' )
, '/folder[@name="', '' )
, '/dashboard[@name=''', '' )
, ''']', ' > ' )


Offline rhythmz

  • Full Member
  • ***
  • Join Date: Jul 2009
  • Posts: 41
  • Forum Citizenship: +0/-0
Re: Returning various parts of the same string
« Reply #2 on: 16 Jun 2017 08:44:06 am »
Unfortunately we are using Oracle...

Not sure if "[Audit Physical].[COGIPF_USERLOGON_SESSION].[COGIPF_USERNAME]" is on the SQL Server side of the house or in the package specific to SQL Server...I have never seen it before...

I'll try to play with it and see what I can create.

Thanks so much for responding to this "inquiring minds need to know" moment for me!!!

Offline Lynn

  • Statesman
  • ******
  • Join Date: Apr 2008
  • Posts: 2,610
  • Forum Citizenship: +335/-1
Re: Returning various parts of the same string
« Reply #3 on: 16 Jun 2017 09:07:46 am »
The Audit Physical namespace is unique to our environment since I have enhanced the audit model beyond what IBM delivers as standard. You should, however, find all the COGIPF stuff in your audit database. Oracle is a more robust database than SQL Server so you should have no problem finding equivalent functionality for replace and substring. If you have support for regular expressions (REGEXP_REPLACE) then you could make this expression more elegant.

Good luck!

 


       
Twittear