Using Vim to Count Patterns

The other day, I posted a trick on using Vim with flat files.  Well, today, I wanted to count the number of times certain data conditions appeared in my file.  I created statistics on my program to show the count, but I wanted to check them to make sure the code was right.  I found this command would do the trick in Vim:

:%s/<pattern>//n

The “s” is the part that does a search and replace, but the “n” tells it to only count the matches rather than replace it with anything.  So, if I wanted to count the number of lines with “0” in the 123rd position, I would use this:

:%/^.\{122}0//n

Here is where I found the trick:

Wiki Technology – Vim: Count number of matches of a pattern

Extracurricular at Oracle

I came across a link to Team Oracle the other day.  I didn’t realize that they have their own Air Show team!  I’ll have to watch the schedule to see if I can catch them in our area.

While we are on the topic, I did already know that Oracle has their own Yacht Racing team.  You can check out BMW Oracle Racing here.

Now, we just need a Basketball team!  We could have Oracle Arena and the mascot could be the CPU Chips.  Maybe that is too much imagination.

Evaluate in SQR

I did a quick little test on the Evaluate syntax in SQR.  I can’t ever remember how the break statement works and if it is required.  So, here is the test —

Here is the code:

  move 1 to #test
  while #test < 6
    show 'Test = ' #test
    evaluate #test
      when = 1
      when = 2
        show 'evaluated as 1 or 2'
      when = 3
        show 'evaluated as 3'
      when = 4
        show 'evaluated as 4'
      when-other
        show 'evaluated as other'
    end-evaluate
    add 1 to #test
  end-while

Here is the output:

Test = 1.000000
evaluated as 1 or 2
Test = 2.000000
evaluated as 1 or 2
Test = 3.000000
evaluated as 3
Test = 4.000000
evaluated as 4
Test = 5.000000
evaluated as other

Vim Search in Flat Files

I have been working with Flat Files recently, and I found Vim Search patterns can help with finding certain conditions within the file.  This pattern works very well:

\{n}

Searches for n number of the preceding pattern.

For example, say you want to find any lines in the file that have a “2” in the 51st position of the file.  You can use this pattern:

^.\{50}2

So, this matches 50 characters of anything and a “2” following.

Reference:

Softpanorama: Vim Regular Expressions

Instructions for Cloning a Database

In an OTN Discussion Thread, I saw that Nicholas Gasparotto pointed out a document with instructions on cloning PeopleSoft instances.

The document is ID #643499.1 on support.oracle.com.  You can find it by pasting the document ID in the search box on the upper right-hand corner just after you login.

The information seemed like it had some great pointers, and if you haven’t already seen it, you might want to read through the steps to make sure you are taking all these things into account.  On the other hand, I think it is very important to keep a step by step list of tasks for your particular system that you keep up to date.  You will probably have specific things that you have to do for your environment that are unique to your installation.  For example, if you are cloning to a test environment, what about blanking out the email addresses so that test emails don’t get sent out as production emails.  Also, some people put a special message in the heading of the test instances so that it is obvious when you are in Test versus Production.

Thanks, Nicholas for the pointer — this is something I want to keep handy.

Record Type Values

Here are the values for the RECTYPE field in the table that stores the information about the records in PeopleSoft: PSRECDEFN.  Here are what the values mean:

  • 0 = SQL Table
  • 1 = SQL View
  • 2 = Work Record
  • 3 = Subrecord
  • 5 = Dynamic View
  • 6 = Query View
  • 7 = Temp Table

For example, you can do something like this to find all the tables that have the OPRID field:

SELECT A.RECNAME
FROM PSRECDEFN A, PSRECFIELDALL B
WHERE A.RECNAME = B.RECNAME
AND A.RECTYPE = 0
AND B.FIELDNAME = 'OPRID'

See the PeopleTools Tables for more information.

PeopleTools 8.50 App Server Location

In installing PeopleTools 8.50/HCM91, I noticed that PeopleTools began placing its Application Server configuration files in a different location.  Instead of finding them in %PS_HOME%/appserv, I found them at %USERPROFILE%\psft\pt\.  The culprit appears to be the PS_CFG_HOME environment variable. I found the documentation for this on page 30 of the Enterprise PeopleTools 8.50 Installation for Oracle (Task 1-5-7: Defining Server Domain Configurations).  I also just found a pretty good link in PeopleBooks about the settings. In order to fix my problem, I did the following:

  • Shut the Application Server and the Process Scheduler Server down
  • Configured the PS_CFG_HOME variable
    • Right click on My Computer
    • Choose Properties
    • Go to the Advanced Tab
    • Click on the Environment Variables
    • Add a new system variable
    • Enter PS_CFG_HOME for the variable name
    • Enter the path to the PeopleSoft Home directory for the value
  • Copied everything from the %USERPROFILE%\psft\pt to the PeopleSoft Home directory.  There were several folders that it wanted to merge, but I didn’t see any files that it wanted to overwrite.  I skipped the peopletools.properties file because it was the same in both locations.
  • Checked the value of %PS_CFG_HOME% in a Command Window.  If the value is not accurate, you might need to close the window and reopen a new one.
  • Reconfigured the Application Server and Process Scheduler (I didn’t change any values, but this let it regenerate the configuration files)
  • Booted the Application Server and Process Scheduler