Oracle

Count Occurrence of a Character in a String

I had the need to count an occurrence of a specific character in a string and after tossing some ideas back and forth between a couple of my colleges, we came up with the below two SQLs. You pass a string and identify the character you are looking to count its occurrence. In both SQLs below, I'm trying to count how many times does ">>" exists in string "This is>>a string>>to look into>>". The answer of course is 3 times.

SQL Option 1:

SELECT COUNT (*)
 FROM (SELECT SUBSTR ('This is>>a string>>to look into>>', ROWNUM, 2 ) s,
              ROWNUM pos

A List of Pages a Peoplesoft Role Name can Access

A query that will take a PeopleSoft role name as an input and returns all pages that could be access by that role. The query will also indicate what kind of operations a user can perform on that page. Example, Add Update/Display and so forth.

SELECT   b.menuname, b.barname, b.baritemname, d.pnlname, c.pageaccessdescr
    FROM psroleclass a,
         psauthitem b,
         pspgeaccessdesc c,
         pspnlgroup d,
         psmenuitem e
   WHERE a.classid = b.classid
     AND d.pnlgrpname = e.pnlgrpname
     AND b.menuname = e.menuname

What Permission Lists does this Role Have?

A query that takes a PeopleSoft role name as a value and returns Permission List(s) associated to that role.

SELECT a.rolename, a.classid AS permission_list
  FROM psroleclass a
 WHERE a.rolename = :rolename;

PeopleSoft Role Queries

A section to collect and organize PeopleSoft Role related queries.