Geeks on Campus

Another amazing bgsu blog

Archive for the 'PS Query' Category

File Size

Posted by jeggent on 19th February 2016

This is just a public service announcement to save network traffic and file storage space.

When you run a query to Excel from PeopleSoft it will initially be in an Excel 2010 .xls file format.  The query results that I just download had 39,181 rows and 10 columns of data.  As an xls file it had a file size of 6,733 KB.  Without making any other changes I saved the file as an Excel 2013 .xlsx file and it reduced the file size to 1,756 KB.  That is almost 75% smaller.

Thank you for your attention.  You may now return to your memes and cat videos.

Posted in Excel, PeopleSoft, PS Query | 6 Comments »

Query get CLOBed?

Posted by jeggent on 9th October 2015


Disclaimer: This may only apply to Oracle databases.

I think my favorite PeopleSoft Query error occurs when you are outputting a CLOB field and try to use an aggregate or DISTINCT.

inconsistent datatypes: expected – got CLOB

The messages always makes me think, “Got Milk?”  The two fields that I seem to run into this the most often with are 3C comments and checklist item Long Description.  In PS Query the fields show as “Text” format, but behind the scenes the content is stored in what is called a CLOB field.  You don’t really need to know the details about how CLOBs are stored in the database, you just need to know when it’s a problem with PS Query and what to do about it.

It seems that you can output a CLOB (Text) field in PS Query just fine.  However, if you mark your query as distinct or make any fields an aggregate (count/sum/etc), you will get the above error message.  The workaround is to create a “Character” type expression, use the TO_CHAR function, and specify a length.  Our checklist item descriptions can be pretty long, so I’ve used a length of 900 in the example below.  You then use your expression as a field instead of the CLOB field from the record.  I hope this helps and maybe solves the mystery of the weird CLOB error. – Cheers, John


Posted in PS Query | 3 Comments »

Left Outer Joining Effective Dated Tables

Posted by jeggent on 18th March 2015

This Changes Everything!

A colleague just taught me how to left-outer-join (LOJ) an effective dated table in PeopleSoft Query.  In the past I would only be able to LOJ non-effective dated tables or use views that had the effective date logic built in.  I just looked through my old posts and it doesn’t look like I’ve posted about LOJs before.  So I’ll give a quick rundown of why you would want to use one.


Say you have three different tables for First, Middle, and Last names.  If you just standard joins you will only see results for those records that are present in all three tables.  But what about my dad?  My dad doesn’t have a middle name.  Weird, I know.  Here is some sample data.

First Name
UID First
1001 John
1002 Larry
1003 Joanne
Middle Name
UID Middle
1001 Isa
1002 The
Last Name
UID Last
1001 Coolguy
1002 Cat
1003 Rowling

So using standard joins and connecting these tables on UID, you would get:
1 John Isa Coolguy
2 Larry The Cat

What about Joanne?  That’s right, JK Rowling also has no middle name.  She gets left out because of the standard join.  However, using a left-outer-join would allow you to make sure that she and any others were not left off.  And that output would look like this:
1001 John Isa Coolguy
1002 Larry The Cat
1003 Joanne  Rowling

Cool, but how?

In PeopleSoft Query, when you go to join a record you will get a “Join Type” box.  Typically you would select Standard Join “Join to filter and get additional fields.  To do an LOJ, you would select the other option “Join to get additional fields only” (Left outer join).  An important thing to remember is that if you need to put any criteria on the LOJed table, you need to specify that the criteria belongs to the ON clause of the outer join in the Edit Criteria Properties box.

So that is how to do a normal LOJ, which I was already comfortable with.  The extra complication is with effective dated tables.  Those tables come with special criteria which is also a subquery.  It isn’t as simple as saying that criteria “belongs” to the left outer join like any other regular criteria.  The magic to make this work is to leave that effective date criteria but then to manually add an additional criteria for the effective date and set the condition type to “is null”.  Then change the logical setting from AND to OR and group those two lines with parenthesis.  As such…loj2

I can only assume that I’ve made your life 1,000% better. Well, we both have Jeff M. to thank. He’s the one that taught it to me.  Let me know in the comments if you have any questions about how to make this work.



Posted in PS Query | 5 Comments »

Unionize your queries

Posted by jeggent on 24th July 2013

I’ve been meaning to write a blog post about unions in PS query for some time now, but I didn’t have a good example to work with until today.  So the scenario is that you want to list out all of the items from record (table) A and the count of their occurrences in record B.  As long as each entry in record A has at least one match in record B that’s fine.  You would just use a standard join and put the COUNT aggregate on a field in record B.  But what to do when there are no matching rows in record B and you don’t want to lose any items from A?

The first idea is to just use a left outer join from A to B and count a field in B.  That works mostly fine except you will get a count of 1 for items that have no rows in record B.  To mitigate the confusion this would cause you can output an additional field from the B record.  That way the additional field from B will only display with the items that have at least one row in B and the others with a count of 1 you will know are really 0.  Given the example of counting the occurrences in STDNT_AWARDS (B) of the item types in ITEM_TYPE_FA (A):

Item    Descr          Count   Year
1234   Pell Grant   1,234   2014
2345  ABC Grant            1
3456  Fed Loan     2,345  2014

You can see that no details from the A  record are lost and the “ABC Grant” has no matching B rows because the year field is blank.

Or you could use a Union

I think a cleaner solution would be to use a Union.  You would create the query first using a standard join and count.  That would result in output such as:

Item    Descr          Count
1234   Pell Grant   1,234
3456  Fed Loan     2,345

Then you would add a Union to the query.  This is done using the “New Union” link at the bottom of the Query Manager page (left of the Return to Search button).  It will look like a new query has been started, but it will say “Working on selection Union 1” at the top.  Select your A record and choose the same fields in the same order as the original query.  * An important point is that the union must have the same number of fields of the same type and in the same order as the main query or you will get an error *  Then create an Expression with a type of number and in the Expression Text box just enter the number 0.  Use this Expression as a field.  Finally add a Does not Exist subquery to the union to only select A rows that have no match in the B record.  Then your output will look like this:

Item    Descr          Count
1234   Pell Grant   1,234
2345  ABC Grant            0
3456  Fed Loan     2,345

*Note that the query will use the field names and sorting specified in the Top Level Query.

That should do it.  Hopefully knowing how to use Unions in PS Query will help you write better queries.

Posted in PeopleSoft, PS Query | 4 Comments »

Cool Running Totals

Posted by jeggent on 5th April 2013

This may be old news to some of you geeks, but I’m pretty excited to figure out how to do running totals in PeopleSoft Query. And, it’s actually pretty easy! In the following example I’m listing Federal Pell Grant disbursements for the aid year with a running total. The first step is to build your query as normal, select the fields you’d like on the output and filter on whatever criteria is correct.  For this example I’ve selected one item type and one aid year.  Next, select the Expressions tab and click on Add Expression. Don’t forget to check the Aggregate Function check box. Here is my expression:

You can see that you are using the SUM function with the field you want the running total for. Then after OVER specify your ORDER BY fields as you would in any other aggregate. Click OK then the Use as Field link to include it in your output. Your output should looks something like this:

ID # Pell $ Running Total
00005 $5,550 $5,550
00009 $2,200 $7,750
00014 $3,100 $10,850

Hopefully you can make good use of running totals in your queries.

Good Luck.

Posted in PS Query | No Comments »

Excel + PS Query = Search Match

Posted by jeggent on 24th August 2012

I’m working on a project to (pop) update a field in PeopleSoft based on a file from an outside source.  The goofy part is that the file does not have a student ID (not surprising), and the first 5 characters of the SSN are masked (more surprising).  So then how do I do a one-to-one match in order to do the update?  What I’ve come up with had a couple of Excel and PS Query tips that I thought were worth sharing.  The first thing I did was create some new columns in the Excel file that is the source data.  To get just the 4 “good” characters of the SSN, I used the RIGHT function.

Equation:  =RIGHT(B4,4)
Translation:  Give me the last 4 characters from the string (text) in cell B4
Example:  ***-**-1234  = 1234

The name in the source data is listed in this format, Last (comma) (space) first (space) middle initial.  To get just the last name from that string I first used the FIND function to get which character position the “,” is in.

Equation:  =FIND(“,”,C4,1)
Translation:  This looks weird because it is a comma that I’m looking for.  The syntax is FIND then what you are looking for in quotes, what cell to look in, and what character position to start looking from.  So this equation says find the comma in cell C4 and start looking at the first character.
Example:  Student, John A = 8  (the comma is the 8th character in the string (name))

Then I use the LEFT function to get the last name.

Equation:  =LEFT(C4,G4-1)
Translation:  In this example G4 has the results of the Find function.  So this says give me the beginning (Left) characters of the string in cell C4 and stop one character before the number G4 (G4 -1).
Example:  G4 = 8 (see above)  Student, John A = Student (left 7 (8-1) characters in the name)

Next I wanted to use the first three characters in the first name.  I only wanted the first three because of the variability of how first names are recorded.  I used the MID function for this.

Equation:  =MID(C4,G4+2,3)
Translation:   MID is like LEFT and RIGHT except it lets you specify a starting point and an ending point.  This equations says: starting two characters after the comma (remember G4 holds the position of the comma and a space follows the comma, G4+2) give me the next three characters.
Example:  G4 = 8  Student, John A = Joh (three characters starting after the comma and the space)

So, those are fields that I am going to match on in PeopleSoft; the last four of the SSN, the last name, and the first three letters of the first name.

We (thankfully) have a process that allows us to upload a file to PeopleSoft to use in a query.  I uploaded this input file and used some criteria with expressions to do the matching from the file to the PEOPLE_SRCH record to get the student ID.  The last name field is a simple EQUAL TO criteria then I compare the last four of the SSN in the input file to the expression SUBSTR(B.NATIONAL_ID,-4).  The function SUBSTR typically works like the LEFT function in Excel where you specify a field and a number to get the first given number of characters in that text.  However (HOT TIP) if you use a negative number, as I did, it will work like the RIGHT function in Excel and give you the last given number of characters in that text.

For the first name comparison I used the expression SUBSTR(B.FIRST_NAME_SRCH,1,3).  When used with two number parameters SUBSTR works like Excel’s MID, so this expression gets the first (because the first number parameter is 1) three characters of the first name.

I double checked the results and using these three criteria I am able to get the student ID for those in the input file.  While you may never have this same exact situation, hopefully you’ll find parts of this post useful in other projects.


Posted in Excel, PeopleSoft, PS Query | 2 Comments »

SUM for Fewer Rows

Posted by jeggent on 21st July 2011

You likely already know that you can use an Aggregate like SUM to reduce multiple query results rows to a single row.  But did you ever think about using it with a couple of functions to display multiple values in a single row?


A simple example of a SUM to reduce rows, would be summing the offer amounts of all of a student’s awards to display their total offers.

A more advanced example using SUM with functions would be to display the Summer, Fall, and Spring semester amounts on a single row.  For this example I will be using the STNDT_DISB_AWD record.  For you non-Financial Aid people I will clarify that in this record the award amounts are listed by term, so without any aggregate function the amounts would be shown on separate rows.  The next step will be to create three functions, one for each term:

*note: ‘2115’, ‘2118’, and ‘2122’ are our terms for Summer, Fall, and Spring

Use those functions as fields and select the SUM aggregate for them.

Without the functions and aggregate the data could have looked like this:

EMPLID             TERM    OFFER
0012345678   2115      1000.00
0012345678   2118      2000.00
0012345678   2122      2000.00

With the functions and aggregates the data could look like this:

EMPLID             Summer Offer   Fall Offer   Spring Offer
0012345678    1000.00             2000.00     2000.00

I hope you find this useful.


Posted in PeopleSoft, PS Query | 2 Comments »

PS Query – Decode Function

Posted by jeggent on 12th July 2011

As expected, the previous semester was very busy.  The next semester will likely be even busier.  However it will also be my last semester.  Assuming I am able to complete the two classes, I will graduate this December.

Today I have used the DECODE function for the first time in a PeopleSoft query.  I am not sure which databases this function works with, we are on an Oracle DB.  Decode allows you to display a specific value based on the contents of a field.  For example, if a field contained integers you could output the corresponding letter of the alphabet.  The syntax of the function is like:

DECODE(Field, Value 1, Output 1, Value 2, Output 2, Else)

Alphabet example:

DECODE(A.Field, 1, ‘A’, 2, ‘B’, 3, ‘C’, 4, ‘D’, …., 36, ‘Z’, ‘other’)

I am using this function in a report for repackaging aid.  I am “decoding” the currently packaged item type to the item type it needs to be replaced with.  If there are multiple values that translate to the same output then you may want to consider a CASE statement with an IN list.  Maybe I’ll go over that next.  Hopefully before Fall semester starts 🙂

Good Luck.


Posted in PeopleSoft, PS Query | 4 Comments »

Drilling URL

Posted by jeggent on 9th May 2011

Cool New Tool: Drilling URL

In starting loan origination for 2011-2012, I wanted to know what status all of the loans were left in after running the process.  So I created a really quick query to just count the IDs by loan status for the aid year.  When I saw that some loans were in a “Hold” status I wanted to then get the listing of those IDs so that I could go and look at those accounts.  This reminded me of the drilling URL example from the Maximizing the use of PS Query for Financial Aid session from the Alliance 2011 conference.  After setting up the Drilling URL, I am able to just click on the loan status and see a listing of all the loans in that status.  There are lots of examples that I can think of that this technique would be useful for.  A department could show the count of students in their classes for a semester and click the class name to show a roster of students in the class.  I will now step you through setting up a query with a Drilling URL.

A drilling URL actually connects two different queries.  So the first step is to create what I will refer to as the detail query, the query with the specific listing that will be reached by clicking the link in the top level query.  In my example this is the BG_FA_LOAN_STATUS_DETAIL query.

For my detail query I am just going to output a few fields from the LOAN_ORIG_DTL record along with the student’s name.  The first important step is to create the Prompts in this query that will be part of the linking process from the top level query.  I want to list the details for all of the loans in a given status for a given aid year, so my two prompts will be for Aid_Year and LOAN_PROC_STAT.

Of course these prompts must be in the Criteria of the query in order to be used.

Next, save this query and begin a new query.  My top level query is called BG_FA_LOAN_STATUS.  It will display a count of records in each loan status by aid year (prompting for aid year).  You’ll see that I have a “Count” on A.EMPLID and I am displaying LOAN_PROC_STAT twice.  This is because I want to display the long translate of the field for the user (note the ‘L” in XLAT) but I also need the one character code to use in the prompt of the detail query.  To do this I just created an expression that is simply A.LOAN_PROC_STAT, displayed that expression and used the translate on the actual field.  The aid year is also displayed and will be used for the detail prompt.

Now you need to setup the Drilling URL.  In “Expressions”, click the Add Expression button and select “Drilling URL” from the Expression Type drop-down.  (the expression text will get filled in for you after completing the following steps).

There are different Drilling URLs that you can use, but we want a Query URL, so click the Query URL link.  You can now search for the detail query that you will be linking to.  It will bring in the prompts from that query (URL Keys) and you choose the fields from your query to populate those prompts.  You also choose (in Map URL to Query Columns) which value or values to turn into clickable links, I am only using the translate of the LOAN_PROC_STAT as the hyperlink, but any or all of the fields can be used to the same effect.

That’s it!  Now when you run this query the Status field will be a link that you can click to get the detailed listing.  Let me know if you try this and have any questions.  Enjoy!

Posted in Financial Aid, PeopleSoft, PS Query, Tools | 10 Comments »

Prior Aid Year

Posted by jeggent on 26th January 2011

Not that I’m ever the poster boy for reliable blog posting, but I’m probably not going to be posting much until award notification go out in mid-March.  I just wanted to give that warning so you don’t think the blog has been abandoned if there are a couple of weeks without an update.  I do have one little PS Query trick for you today though.  In creating a new Pop Select query for aid year activation I wanted to check for an award offer in the prior aid year.  Sure I could have just prompted for the prior aid year and used that, but I was already prompting for the new aid year and didn’t think both should have to be entered.  The solution was to use the following criteria in an “Exists” subquery:

Best of luck!

Posted in Financial Aid, PeopleSoft, PS Query | 2 Comments »