Given a scenario where we our organization have multiple accounting structures and we require to dynamicallly construct the column list and its values for a given code combination id use the below anonymous block
SET serveroutput on;
set verify off;
set feedback off;
DECLARE
CURSOR C_SEGMENT_STRUCTURE(p_coa IN NUMBER) IS
SELECT SEGMENT_NAME
FROM FND_ID_FLEX_SEGMENTS_VL
where id_flex_num=p_coa;
N NUMBER:=0;
M NUMBER:=0;
V_COA_ID NUMBER;
V_COLUMN VARCHAR2(200);
V_SELECT VARCHAR2(200);
V_SEGMENT VARCHAR2(200);
v_ccid NUMBER:=230454205;--ccid;
V_RESULT VARCHAR2(200);
v_query VARCHAR2(1000);
BEGIN
SELECT chart_of_accounts_id
INTO v_coa_id
FROM gl_code_combinations
WHERE code_combination_id=V_CCID;
IF v_coa_id > 0 THEN
FOR r IN C_SEGMENT_STRUCTURE(v_coa_id) LOOP
N:=N+1;
IF n=1 then
v_column :=rpad(r.SEGMENT_NAME,12,' ');
ELSE
v_column :=v_column||rpad(r.SEGMENT_NAME,12,' ');
END IF;
END LOOP;
DBMS_OUTPUT.PUT_LINE(V_COLUMN);
FOR S IN 1..N LOOP
M:=M+1;
V_SEGMENT:='rpad(SEGMENT'||S||',12,'' '')';
IF M=1 THEN
V_SELECT:=V_SEGMENT;
ELSE
V_SELECT:=V_SELECT||'||'||V_SEGMENT;
END IF;
END LOOP;
-- DBMS_OUTPUT.PUT_LINE('Select '||V_SELECT);
v_query:='SELECT '||v_select
||' from gl_code_combinations'
||' where code_combination_id=:1';
EXECUTE IMMEDIATE v_query INTO v_result USING V_CCID;
DBMS_OUTPUT.PUT_LINE(v_result);
END IF;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Invalid CCID '||SQLERRM);
END;
/
set verify on;
set feedback on;
Building an FMW Cluster using Docker (Part III Running Docker Containers)
-
Click here for a Google Docs version of this document that doesn't suffer
from the Oracle blog formatting problems
Oracle Fusion Middleware Deployment...
7 years ago
No comments:
Post a Comment