Friday, January 23, 2015

Capturing Errors in XU2 Scripts Early in Stage 4 of a View Regeneration Using MS PowerShell

--This is a re-post

I posted on this previously and documented a MS DOS command to find errors in my XU2 scripts (here).The xu2 scripts are invoked during stage 4 of the Noetix View Administrator's regeneration process.  This is right after SQL Loader is finished loading seeded template table records. The errors that are thrown during this part of the regeneration are typically associated with constraint errors.  If you examine the constraints that are associated with a given Noetix template table, one can see that they are quite robustly written to help make sure that you do not add a record in an erroneous way.

One can typically examine the root cause of these errors if one looks at this query:

 WHERE 1          = 1

Today I wanted to document another way to find these errors.  More than a year ago, I noticed that Microsoft had an updated shell, called PowerShell, and so I placed it on my laptop and did not do anything with it. I noticed that it was quite different from MS Dos and I looked at it for a little bit and talked to some peers.  My peers heard of it, but thought that it really had gained little traction in terms of use by administrators and other IT staff. For one reason or another, I stumbled on the blog,, and it really made me reconsider using this shell environment in lieu of MS DOS where practical.
Anyway, the two main commands one needs to know in this shell are as follows:
Get-Alias  MS_DOS_Command
Notes on this:  This cmdlet just helps you translate your MS DOS command to the PowerShell cmdlet.
Here is an example:
PS C:\WINDOWS\system32\windowspowershell\v1.0> Get-Alias cd
This returns:
CommandType     Name                                                                                           Definition                                                                                    
-----------     ----                                                                                           ----------                                                                                    
Alias           cd                                                                                             Set-Location         
The other command that is necessary is the following:
Get-Help cmdlet
Today, I will go through how one can invoke a command (well, actually a cmdlet) to find Oracle thrown errors that occur while the Noetix View Administrator is in stage 4 of a regeneration.

First, a little background information on PowerShell.
It is rather nice because it is object oriented and its piping is similar to Unix/Linux.  Specifically, the piping can return objects and then the next cmdlet (that is what they call their commands in this new shell) manipulates it, one object at a time through the pipe kind of like an embedded function.  This is very dissimilar to MS DOS where it completes the first command and then pushes the result set to the next command.
Anyways, I use this shell as my main shell that I use for various tasks.  Here is my cmdlet to watch for errors being thrown right before GUI prompt for the APPS password (which is right after the wnoetxu2.sql script has run):
Get-ChildItem -Path "\\cmntx02\NoetixViews 6.0.1 - ERP\Installs\NOETIX_SYS_erpdev" -Filter "*xu2.lst" | Select-String -pattern "ORA-"
  The Get-ChildItem cmdlet gets the items in one or more specified locations. In this context it obtains all the xu2.lst spooled files and pipes the results to the Select-String cmdlet which finds matches to the pattern, "ORA-".
I invoke this script on my laptop and it peruses the files in the path I have identified.  I suppose you might take a look at this script and think; I will never type a path that long!  Well, if you are not aware, you can drag a file from MS explorer to your shell environment and Windows will “type it in” for you.