0% found this document useful (0 votes)
3 views

Print_cursor

The document contains a PL/SQL block that constructs and executes a dynamic SQL query based on a condition. It retrieves application and responsibility details from various tables, formatting dates and filtering based on specific criteria. The results are returned as a cursor for further processing.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Print_cursor

The document contains a PL/SQL block that constructs and executes a dynamic SQL query based on a condition. It retrieves application and responsibility details from various tables, formatting dates and filtering based on specific criteria. The results are returned as a cursor for further processing.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

VARIABLE cur_open REFCURSOR;

DECLARE
l_query_str CLOB;
cur_open SYS_REFCURSOR;
BEGIN
IF UPPER(LTRIM(RTRIM('$$appspecific$$')))='NO' THEN
BEGIN
l_query_str :=
' SELECT MAX(fa.application_id) APPLICATION_ID,
MAX(fa.application_short_name) as APPNAME,
to_char(MAX(fr.last_update_date),''DD/MM/YYYY'') LAST_UPDATE_DATE ,
to_char(MAX(fr.creation_date),''DD/MM/YYYY'') CREATION_DATE ,
TRIM(fr.responsibility_key) RESPONSIBILITY_KEY,
MAX(trim(frt.responsibility_name) ) AS DESCRIPTION,
MAX(frt.language) LANGUAGE,
''$$roletype_responsibility$$'' ROLE_TYPE,
TO_CHAR(MAX(fr.responsibility_id)) AS RESPONSIBILITY_ID
FROM fnd_responsibility_tl frt,
fnd_application fa,
fnd_responsibility fr
WHERE frt.responsibility_id = fr.responsibility_id
AND frt.application_id = fr.application_id
AND fa.application_id = fr.application_id
AND (fr.end_date IS NULL OR TRUNC(fr.end_date) > TRUNC(SYSDATE))
AND NVL(TRUNC(fr.start_Date),TRUNC(SYSDATE)) <=TRUNC(SYSDATE)
AND EXISTS (SELECT 1 FROM fnd_languages ln
WHERE ln.language_code= frt.language
AND installed_flag = ''B'')
GROUP BY fr.responsibility_key
UNION
SELECT 0 APPLICATION_ID,
'''' as APPNAME,
to_char(LAST_UPDATE_DATE,''DD/MM/YYYY'') LAST_UPDATE_DATE ,
to_char(sysdate,''DD/MM/YYYY'') CREATION_DATE ,
NAME RESPONSIBILITY_KEY,
DISPLAY_NAME AS DESCRIPTION,
LANGUAGE,
''$$roletype_umxrole$$'' ROLE_TYPE,
'' '' AS RESPONSIBILITY_ID
FROM WF_LOCAL_ROLES WHERE UPPER(name) LIKE ''UMX%''
ORDER BY 4 ';
END;
ELSE
BEGIN
l_query_str :=
' SELECT fa.application_id APPLICATION_ID,
fa.application_short_name as APPNAME,
to_char(fr.last_update_date,''DD/MM/YYYY'') LAST_UPDATE_DATE ,
to_char(fr.creation_date,''DD/MM/YYYY'') CREATION_DATE ,
TRIM(fr.responsibility_key)|| ''/'' || fa.application_short_name
RESPONSIBILITY_KEY,
trim(frt.responsibility_name)AS DESCRIPTION,
frt.LANGUAGE LANGUAGE,
''$$roletype_responsibility$$'' ROLE_TYPE,
TO_CHAR(fr.responsibility_id) AS RESPONSIBILITY_ID
FROM fnd_responsibility_tl frt,
fnd_application fa,
fnd_responsibility fr
WHERE frt.responsibility_id = fr.responsibility_id
AND frt.application_id = fr.application_id
AND fa.application_id = fr.application_id
AND (fr.end_date IS NULL OR TRUNC(fr.end_date) > TRUNC(SYSDATE))
AND NVL(TRUNC(fr.start_Date),TRUNC(SYSDATE)) <=TRUNC(SYSDATE)
AND EXISTS (SELECT 1 FROM fnd_languages ln
WHERE ln.language_code= frt.language
AND installed_flag = ''B'')
UNION
SELECT 0 APPLICATION_ID,
'''' as APPNAME,
to_char(LAST_UPDATE_DATE,''DD/MM/YYYY'') LAST_UPDATE_DATE ,
to_char(sysdate,''DD/MM/YYYY'') CREATION_DATE ,
NAME RESPONSIBILITY_KEY,
DISPLAY_NAME AS DESCRIPTION,
LANGUAGE,
''$$roletype_umxrole$$'' ROLE_TYPE,
'' '' AS RESPONSIBILITY_ID
FROM WF_LOCAL_ROLES WHERE UPPER(name) LIKE ''UMX%''
ORDER BY 4 ' ;
END;
END IF;
OPEN cur_open FOR l_query_str;
:cur_open := cur_open;
END;
/

PRINT cur_open;

You might also like