ODBC Custom Fields - Students

Using ODBC, I am not able to write the code for the students custom fields.

I can pull all the other info from the students field, but do not know how to write the code for the custom student fields.

I did enable custom fields and rebuild custom fields mirror data and restarted PowerSchool. I am using PS 5.2.1.4 and Oracle SQL Developer.

Thanks for any ideas.

Comments

re: ODBC Custom Fields - Students

Hi Jason, Thanks for the suggestions.
I tried all 3 and here are the results:

For the 1st query, using the multiple left outer joins, the query returns the data in 5 to 10 seconds, but the more fields you add the slower it gets.

The 2nd query, using 1 left outer join and the "group by", the query returns the data in 1 second, no matter how many fields you add.

The 3rd query, well, after 5 minutes I stopped the query because it had not returned any data. I suspect it was trying to do a full join of the data before filtering on the studentid.

Thanks again,
Leslie Stevens
Edmonton Public Schools

oops! I should have clicked on the "reply" link instead of the add comment button. sorry.

ODBC Custom Fields - Students

To get the data from the custom fields I have used the pvsis_custom_students view.

Here is a query I use in SQL Developer to get the data from the students custom fields:

select s.lastfirst, s.student_number, s.grade_level,
NVL(c.text_value,' ') as CustomField1,
NVL(d.text_value,' ') as CustomField2,
NVL(e.text_value,' ') as CustomField3,
NVL(f.text_value,' ') as CustomField4,
TO_NUMBER(NVL(g.char_value,'0')) as CustomField5
from students s
left outer join pvsis_custom_students c
on s.id = c.studentid and c.field_name = 'CustomField1'
left outer join pvsis_custom_students d
on s.id = d.studentid and d.field_name = 'CustomField2'
left outer join pvsis_custom_students e
on s.id = e.studentid and e.field_name = 'CustomField3'
left outer join pvsis_custom_students f
on s.id = f.studentid and f.field_name = 'CustomField4'
left outer join pvsis_custom_students g
on s.id = g.studentid and g.field_name = 'CustomField5'
where s.schoolid = ~(curschoolid)
and s.enroll_status = 0
order by s.lastfirst

I am gathering 4 character fields and 1 numeric field.
I use the NVL function to convert nulls to characters.
I use the TO_NUMBER function to convert a character field to numeric.
I use a "left outer join" to get all the student records and I must do this join for each custom field I want to extract (note the alias letters used for each custom field / join).

Warning: The more custom fields you extract the slower the query runs.

Hope this helps,
Leslie Stevens
Edmonton Public Schools

re: ODBC Custom Fields - Students

Another way to do this is to use 1 left outer join (lets say c) and c.field_name IN ('field1','field2','field3'). You then need to do a MAX(CASE WHEN c.field_name = 'field1' THEN value END) as field1 in your select statement. Lastly you'll need a group by of every field other than your custom fields (GROUP BY s.lastfirst, s.student_number, s.grade_level)

A third way to do it that is much like the way listed is to move your query for each field into the SELECT statement.

select s.lastfirst, s.student_number, s.grade_level,
(SELECT text_value FROM pvsis_custom_students WHERE studentid = s.id and field_name = 'CustomField1') as CustomField1,
(SELECT text_value FROM pvsis_custom_students WHERE studentid = s.id and field_name = 'CustomField2') as CustomField2,
(SELECT text_value FROM pvsis_custom_students WHERE studentid = s.id and field_name = 'CustomField3') as CustomField3,
(SELECT text_value FROM pvsis_custom_students WHERE studentid = s.id and field_name = 'CustomField4') as CustomField4,
TO_NUMBER((SELECT char_value FROM pvsis_custom_students WHERE studentid = s.id and field_name = 'CustomField1')) as CustomField5
from students s
where s.schoolid = ~(curschoolid)
and s.enroll_status = 0
order by s.lastfirst

In my experience I have found that putting the query in the SELECT area instead of doing a left outer join has improved my performance dramatically. Especially when doing so many.

Jason Treadwell
Custom Solutions Specialist
jason@powerdatasolutions.org
www.powerdatasolutions.org

Syndicate content Syndicate content