Here is what our Oracle guru said about this function:
A bit of explanation:
Here is a little more detail on the implementation and usage of these “parameterized” views. We’ll use the SZVLFOS_MAJORS view as an example:
Objects associated with the view:
The database package FSU_SK_VIEW_PARAMS, and . . .
the function FSU_SF_SZVLFOS_MAJR_TERM(term IN VARCHAR2 DEFAULT NULL).
Necessity here was the mother of invention. The code for obtaining a student's primary major was rather cumbersome, producing the desire for a view. However, a student's primary major is based on term so that, while I can join this code to a select from STVTERM to display major records by term for a single student, I can't even begin to that for any significant population of students - hence the need for a parameterized query.
The term parameter for this query is the variable SZVLFOS_MAJR_TERM stored in the package FSU_SK_VIEW_PARAMS. This variable is both read and written by the function FSU_SF_SZVLFOS_MAJR_TERM. When a term is passed to the function, it sets the package variable to that term and returns '0'. When no parameter is passed to the function it will return the value of the variable SZVLFOS_MAJR_TERM.
So, when a call is made to the view, the function must also be called, thereby passing a value to the view. The view then calls the function again, reading and referencing the value of the package variable.
---
-- You can set and read the package variable like this:
--
SET SERVEROUTPUT ON;
BEGIN
SISCVT.FSU_SK_VIEW_PARAMS.szvlfos_majr_term := '200608';
DBMS_OUTPUT.PUT_LINE(FSU_SK_VIEW_PARAMS.szvlfos_majr_term);
END;
--
-- But, there is a better way:
--
SELECT FSU_SF_SZVLFOS_MAJR_TERM('200608') FROM DUAL;
SELECT FSU_SF_SZVLFOS_MAJR_TERM() FROM DUAL;
-- Watch what happens when we do this:
select FSU_SF_SZVLFOS_MAJR_TERM() from dual
where FSU_SF_SZVLFOS_MAJR_TERM('200608') = '0'
and FSU_SF_SZVLFOS_MAJR_TERM('200701') = '0'
-- . . . and then switch the lines around:
select FSU_SF_SZVLFOS_MAJR_TERM() from dual
where FSU_SF_SZVLFOS_MAJR_TERM('200701') = '0'
and FSU_SF_SZVLFOS_MAJR_TERM('200608') = '0'
-- And then do a select:
SELECT * FROM szvlfos_majors
WHERE sorlcur_pidm = 12345
--------------------------------------------
So i need to excute this 'within' the FOCUS session in order to set the package variable.
This works but I get 0 records because I suspect I'm in two different seeesions. It is like running the SQL above without the:
where FSU_SF_SZVLFOS_MAJR_TERM('200608') = '0'
So I need the syntax for running a package with in WebFOCUS, if that is possible. If not I'll just have to use SQL then format the report with WebFocus.
ENGINE SQLORA SET DEFAULT_CONNECTION GOLD
SQL SQLORA
SELECT FSU_SF_SZVLFOS_MAJR_TERM('200608') FROM SZVLFOS_MAJORS;
END
TABLE FILE SZVLFOS_MAJORS
PRINT *
IF RECORDLIMIT EQ 10
END
Reporting Server 7.6.10
Dev. Studio 7.6.8
Windows NT
Excel, HTML, PDF