sqlReports-MO - 2010 MOPSUG Conference

advertisement
sqlReports
Dean Dahlvang
PSUG-MO
March 2010
About Dean
• Dean Dahlvang (ddahlvan@proctor.k12.mn.us)
• Director of Administrative Technology for the Proctor
Public Schools (just outside of Duluth, Minnesota at
the tip of Lake Superior).
• PowerSchool Admin for 9 years, PowerSchool
contracted state reporting programmer for the last 4
years.
• I have never used a wood chipper.
What is sqlReports?
• sqlReports is a simple way of creating sql queries inside of
PowerSchool without the need to have a traditional sql client
and odbc access. Both of those things definitely help
however.
• It allows you to create queries that are available to end users
to execute.
• It is like a fancy List Students function only you can query any
table or view, save the query for repeated use and export the
query and give it to goofy Uncle Eugene at Thanksgiving.
Downloading sqlReports
• sqlReports can be downloaded from the
PowerDataSolutions website:
– www.powerdatasolutions.org
• You will need to create an account in order to login
and download anything from PDS
Installing sqlReports
• After downloading the zip file from PDS, uncompress
it and place the sqlReports folder in the admin folder
of your custom web_root.
• For more details on adding custom pages see the
following:
– Link to pds for custom pages
Adding sqlReport to the Reports Menu
• In order to quickly access sqlReports, it is nice to add
it to the main reports menu. This is not required but
certainly makes navigation easier.
• Modify admin/reports/reporttabs.html
<!-- dean sqlReports added -->
<td class="tab_end~[if.~[gpv:repType]=power]_sel[/if]"><img src="/images/spacer.gif" width="4" height="15" /></td>
<td class="tab_td~[if.~[gpv:repType]=sqlReports]_sel[/if]">
<div class="tab_outter~[if.~[gpv:repType]=sqlReports]_sel[/if]">
<div class="tab_content~[if.~[gpv:repType]=sqlReports]_sel[/if]">
~[if.~[gpv:repType]=sqlReports]sqlReports[else]
<a href="/admin/sqlReports/home.html?frn=~(userfrn)">sqlReports</a>[/if]</div>
</div>
</td>
<!-- end of dean sqlReports -->
Using sqlReports
• Now that sqlReports is installed, how do we use it?
• Navigate to Reports and select sqlReports from the
tabs.
• In order to create a new report your user account
needs to be part of Group 9 (Administrators).
• Click the link to Create a new sqlReport link.
A New sqlReport
• First thing – try using the sqlReports help in the
upper right corner if you get stuck
• A very simple report to list teachers
•
Report Name: Teacher List
Report Title: Teacher List
Report Description: Teacher List
Report Header: <td>Name</td><td>Email</td>
sql Query: select lastfirst, email_addr from teachers
•
Next…the tricky part
Fixing the sql to Work with sqlReports
• Once the raw sql is entered (this is where a
traditional query tool is helpful), we need to tag the
command to work with sqlReports.
• Tagging the sql will basically turn the query that may
produce multiple columns of data in to one that
produces just ONE column of data with the proper
web table tags included.
• To tag the sql, just click the Add Tags link.
More on Tagging the sql
• Initially our sql looked like:
–
select lastfirst, email_addr from teachers
• Now it looks like this:
–
select '<td>'|| lastfirst||'</td><td>'|| email_addr||'</td>' from
teachers
• Notice the <td> tags and the || (pipes). This helps
form the columns for the tlist_sql that is running the
show.
• Once the sql is tagged, submit our first sqlReport.
Running the sqlReport
• From the sqlReports menu, click the name of the
report (Teacher List).
• A screen appears to execute the sql. If we would
have specified parameters for the report, we could
have entered them here.
• Click submit to see the report in action.
• *Poof* instant report.
Lets Try Parameters
• Suppose our list of teachers should have been
selected based on their schoolid. We can do that
with the parameters. We can use up to 5 total
parameters with sqlReports.
• Edit the Teachers List report by clicking the Edit link
on the right side.
Parameters
• Modify the sql Query to look like this:
–
select lastfirst, email_addr, schoolid from teachers
where schoolid in (%param1%)
• Adding the schoolid as a select field makes sense, what about
the where clause?
• Using the in function allows for multiple comma delimited
options.
• The %param1% code is sqlReports way of handling the
parameter 1. Use %param2%, etc for more parameters.
• Be sure to tag the sql and add Schoolid to the header!
More on Parameters
• In the Optional Parameters section, give parameter 1
a Name to Display (like School Number).
• Also, set a default value, if you want one.
• Submit the page to save the report.
Running a Parameter Report
• Back the sqlReports menu, click the Teacher List
report to execute it.
• A page appears asking for the School Number and
may have a default value already entered.
• Make sure we have a value in the School Number
field and submit this page.
• The resulting report should be a list of teachers for
the school number selected.
Advanced Features
• UnTag – Tries to remove previous tagging and
populates the parameters of the sql. This can then
be copy and pasted in to a sql query tool.
• Student Selections – obviously this is for student
based queries. Turning on the check box actives the
Student Selection Query. This query is basically
identical to the main query except that it just selects
DCID.
Wait! There are Even More Advanced
Features
• Include Row Number – adds row numbers (huh?
Who would have thought?)
• Open in a New Window
• Display Debug Info – displays the exact query just
before it is run through the tlist_sql command
• Last Run Info – identifies is the report is used often
Importing and Exporting
• To export a query in sqlReports, simply just edit the
query. At the bottom, right click on the link to export
the query and choose Save As to save the query in a
text file format.
• To import a query, open an exported text file with
your favorite editor. Copy the entire contents to the
clipboard. Select the Import a new sqlReport option
and paste the query in the text box provided. Submit
the change and the query is now imported.
Let’s Look at Some Examples
• The Birthday List
• The F List
– This includes the Student Selection Function
Download