Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
PACKAGE BODY EMP_TOOLS
AS
PROCEDURE display_emp (Resultset IN OUT EMP_CURSOR, MYSORTORDER VARCHAR2)
IS
l_sortorder VARCHAR2(20);
l_sql_stmt VARCHAR2(2000);
BEGIN
-- check innput parameters
IF ( MYSORTORDER IS NULL ) THEN
l_sortorder := 'EMPNO';
ELSE
l_sortorder := MYSORTORDER;
END IF;
-- create dynamic query
l_sql_stmt :=
'SELECT EMP.EMPNO EMPNO, EMP.ENAME ENAME , EMP.SAL SAL
FROM EMP
WHERE 1=1
ORDER BY '||l_sortorder;
OPEN Resultset
FOR
SELECT EMP.EMPNO EMPNO, EMP.ENAME ENAME , EMP.SAL SAL
FROM EMP
WHERE 1=1
ORDER BY MYSORTORDER;
--- alternative: Resultset with dynamic query
--OPEN Resultset
--FOR l_sql_stmt;
EXCEPTION
WHEN VALUE_ERROR THEN
NULL;
WHEN OTHERS THEN
NULL;
END display_emp;
END EMP_TOOLS;
l_sql_stmt :=
'SELECT EMP.EMPNO EMPNO, EMP.ENAME ENAME , EMP.SAL SAL
FROM EMP
WHERE 1=1
ORDER BY '||l_sortorder;
OPEN Resultset
FOR
SELECT EMP.EMPNO EMPNO, EMP.ENAME ENAME , EMP.SAL SAL
FROM EMP
WHERE 1=1
ORDER BY MYSORTORDER;
OPEN Resultset
FOR
SELECT EMP.EMPNO EMPNO, EMP.ENAME ENAME , EMP.SAL SAL
FROM EMP
WHERE 1=1
ORDER BY 'EMPNO';
OPEN Resultset
FOR l_sql_stmt;
OPEN Resultset
FOR
SELECT EMP.EMPNO EMPNO, EMP.ENAME ENAME , EMP.SAL SAL
FROM EMP
ORDER BY MYSORTORDER;
--OPEN Resultset
--FOR
--SELECT EMP.EMPNO EMPNO, EMP.ENAME ENAME , EMP.SAL SAL
--FROM EMP
--WHERE 1=1
--ORDER BY MYSORTORDER;
OPEN Resultset
FOR l_sql_stmt;
..
if upper(MYSORTORDER) = 'EMPNO' then
OPEN Resultset
FOR
SELECT EMP.EMPNO EMPNO, EMP.ENAME ENAME ,EMP.SAL SAL
FROM EMP
ORDER BY EMPNO;
elsif upper(MYSORTORDER) = 'DEPTNO' then
OPEN Resultset
FOR
SELECT EMP.EMPNO EMPNO, EMP.ENAME ENAME ,EMP.SAL SAL
FROM EMP
ORDER BY DEPTNO;
....
SET_BLOCK_PROPERTY('EMP_BLOCK', ORDER_BY, 'ENAME ASC');
GO_BLOCK('EMP_BLOCK');
CLEAR_BLOCK(No_Validate);
--- here the stored procedure is started
EXECUTE_QUERY;
PACKAGE EMP_TOOLS IS
TYPE EMP_REC IS RECORD(
EMPNO EMP.EMPNO%TYPE,
ENAME EMP.ENAME%TYPE,
SAL EMP.SAL%TYPE
);
TYPE EMP_CURSOR IS REF CURSOR RETURN EMP_REC;
PROCEDURE display_emp (Resultset IN OUT EMP_CURSOR, MYSORTORDER VARCHAR2);
END EMP_TOOLS;
OPEN Resultset
FOR l_sql_stmt;