PL/sql issue

Hey,
I tryed to use forall like this and its thorwing an error like this.
PLS-00435: DML statement without BULK In-BIND cannot be used inside FORALL
Please Help me regarding this issue and am trying insert bulkcollect and but its throwing an error mismatch collection types.
CREATE TYPE cust_test AS OBJECT
COMP_PLAN_CD VARCHAR2(10 CHAR),
COMP_PLAN_NM VARCHAR2(40 CHAR),
COMP_PLAN_ID NUMBER
Type created
CREATE TYPE cust_ntt AS TABLE OF cust_test
Type created
Part of procedure,where i want to insert Forall and Bulk collect
nt_cust cust_ntt;
PROCEDURE do_insert
IS
PROCEDURE process_insert_record
IS
CURSOR c_es_div_split
IS
SELECT div_id
FROM ZREP_MPG_DIV
WHERE div_id IN ('PC','BP','BI','CI','CR');
PROCEDURE write_record
IS
CURSOR c_plan_fields
IS
SELECT x.comp_plan_id, x.comp_plan_cd, cp.comp_plan_nm
FROM cp_div_xref@dm x, comp_plan@dm cp
WHERE x.comp_plan_id = cp.comp_plan_id
AND x.div = v_div
AND x.sorg_cd = v_sorg_cd
AND x.comp_plan_yr = TO_NUMBER (TO_CHAR (v_to_dt, 'yyyy'));
BEGIN -- write_record
OPEN c_plan_fields;
FETCH c_plan_fields INTO v_plan_id, v_plan_cd, v_plan_nm;
CLOSE c_plan_fields;
forall i in 1.. nt_cust.count
INSERT INTO CUST_HIER
sorg_cd,cust_cd,bunt, div,from_dt,to_dt,cust_ter_cd,cust_rgn_cd,cust_grp_cd,
cust_area_cd,sorg_desc,CUST_NM,cust_ter_desc,cust_rgn_desc,
cust_grp_desc,cust_area_desc,cust_mkt_cd,cust_mkt_desc,
curr_flag,last_mth_flag,comp_plan_id,comp_plan_cd,comp_plan_nm,asgn_typ,
lddt
VALUES (
v_sorg_cd,v_cust_cd,v_bunt, v_div,TRUNC (v_from_dt),
TO_DATE ( TO_CHAR (v_to_dt, 'mmddyyyy') || '235959',
'mmddyyyyhh24miss'),
v_ter,v_rgn,v_grp,v_area,v_sorg_desc,v_cust_nm,v_cust_ter_desc,v_rgn_desc,v_grp_desc,v_area_desc,v_mkt,v_mkt_desc,v_curr_flag,v_last_mth_flag,v_plan_id,
v_plan_cd,v_plan_nm,v_asgn_typ,v_begin_dt
v_plan_id := 0;
v_plan_cd := 0;
v_plan_nm := NULL;
v_out_cnt := v_out_cnt + 1;
IF doing_both
THEN
COMMIT;
ELSE
-- commiting v_commit_rows rows at a time.
IF v_out_cnt >= v_commit_cnt
THEN
COMMIT;
p.l ( 'Commit point reached: ' || v_out_cnt || 'at: ' ||
TO_CHAR (SYSDATE, 'mm/dd hh24:mi:ss'));
v_commit_cnt := v_commit_cnt + v_commit_rows;
END IF;
END IF;
END write_record;
Waiting for your valueable responses.
Thanks..

here is whole am trying to compile...its throwing error
PLS-00302: component 'COMP_PLAN_ID' must be declared( i highlted the error line in below code)...
CREATE OR REPLACE PROCEDURE DW.load_cust_hier
AS
/* VARIABLES */
v_in_cnt NUMBER;
v_out_cnt NUMBER;
v_tot_in NUMBER := 0;
v_tot_out NUMBER := 0;
v_updt_cnt NUMBER;
v_dup_cnt NUMBER;
v_commit_rows NUMBER := 10000;
v_commit_cnt NUMBER := 10000;
v_begin_dt DATE;
v_end_dt DATE;
v_last_mth_dt DATE; --last bus month END DATE
v_last_day_dt DATE; --last bus day END DATE
first_rec BOOLEAN := TRUE;
doing_both BOOLEAN := FALSE;
mpg_only BOOLEAN := FALSE;
v_next_row NUMBER;
last_targ NUMBER;
last_rec BOOLEAN;
no_targ_found BOOLEAN;
write_dup BOOLEAN;
v_orig_from_dt DATE;
v_orig_to_dt DATE;
v_from_yr NUMBER (4);
v_to_yr NUMBER (4);
v_yr_diff NUMBER (4);
-- Variables for cust_hier fields
v_sorg_cd cust_hier.sorg_cd%TYPE;
v_cust_cd cust_hier.cust_cd%TYPE;
v_bunt cust_hier.bunt%TYPE; --DP
v_div cust_hier.div%TYPE;
v_from_dt cust_hier.from_dt%TYPE; -- source from_dt
v_to_dt cust_hier.to_dt%TYPE; -- source to_dt
v_from_dt_orig cust_hier.from_dt%TYPE; -- original from_dt
v_to_dt_orig cust_hier.to_dt%TYPE; -- original to_dt
t_from_dt cust_hier.from_dt%TYPE; -- target from_dt
t_to_dt cust_hier.to_dt%TYPE; -- target to_dt
v_ter cust_hier.cust_ter_cd%TYPE;
v_rgn cust_hier.cust_rgn_cd%TYPE;
v_grp cust_hier.cust_grp_cd%TYPE;
v_area cust_hier.cust_area_cd%TYPE;
v_mkt cust_hier.cust_mkt_cd%TYPE;
v_sorg_desc cust_hier.sorg_desc%TYPE;
v_cust_nm cust_hier.cust_nm%TYPE;
v_cust_ter_desc cust_hier.cust_ter_desc%TYPE;
v_rgn_desc cust_hier.cust_rgn_desc%TYPE;
v_grp_desc cust_hier.cust_grp_desc%TYPE;
v_area_desc cust_hier.cust_area_desc%TYPE;
v_mkt_desc cust_hier.cust_mkt_desc%TYPE;
v_curr_flag cust_hier.curr_flag%TYPE;
v_last_mth_flag cust_hier.last_mth_flag%TYPE;
v_asgn_typ cust_hier.asgn_typ%TYPE;
v_plan_cd cust_hier.comp_plan_cd%TYPE;
v_plan_nm cust_hier.comp_plan_nm%TYPE;
v_plan_id cust_hier.comp_plan_id%TYPE;
v_mpg mpg_div_s004.mpg_id%TYPE;
v_src_values VARCHAR2 (2000);
v_prev_values VARCHAR2 (2000);
/* Error handling variables */
v_error_code NUMBER;
v_error_message VARCHAR2 (200);
/* CURSORS */
** Source records - CUSTs with only ONE of DIV or MPG type assignment
** Used in sequential logic, no reading of committed records.
CURSOR c_mpg
IS
SELECT /*+ ALL_ROWS */
DISTINCT sorg_cd, mpg, bunt, --DP
bunt_orig, -- ES/CS 5/2002
div, cust_cd, to_dt,
from_dt, cust_rgn_cd, cust_grp_cd, cust_area_cd,
cust_nm, cust_rgn_desc, cust_grp_desc, cust_area_desc,
sorg_desc, cust_ter_cd, cust_ter_desc, mkt_cd,
mkt_desc, 'mpg' asgn_typ, dflt_flag
FROM cust_hier_tab z
WHERE sorg_cd IN ('S004')
AND z.mpg IN ('01', '02', '05', '06')
--AND z.cust_cd = '27174'
ORDER BY z.sorg_cd,
z.mpg,
z.cust_cd,
z.to_dt DESC,
z.dflt_flag DESC,
z.from_dt DESC;
-- changed cursor this record is based on from c_mpg_only to c_mpg 5/2002 CJL
src_rec c_mpg%ROWTYPE;
** Source records - CUSTs with mpg assignments only assign for AB,AF,PC,RD
** Used in sequential logic, no reading of committed records.
** Added NV and VS, CS 5/2002.
** Added AX 12/2005
** Added VC 8/2006
CURSOR c_div_only_mpg
IS
SELECT /*+ ALL_ROWS */
DISTINCT z.sorg_cd, z.mpg, z.bunt, -- DP
z.bunt_orig, -- ES/CS 5/2002
NVL (zd.div_id, 'na') div, cust_cd, to_dt, from_dt,
cust_rgn_cd, cust_grp_cd, cust_area_cd, cust_nm,
cust_rgn_desc, cust_grp_desc, cust_area_desc, sorg_desc,
cust_ter_cd, cust_ter_desc, mkt_cd, mkt_desc,
DECODE (z.div, 'na', 'mpg', 'div') asgn_typ, dflt_flag
FROM cust_hier_tab z, zrep_mpg_div zd
WHERE sorg_cd IN ('S004', 'S096')
AND (z.mpg = zd.mpg_id OR z.div = zd.div_id)
-- Added NV, VS, CS 5/2002
-- Added AX 12/2005
-- Added VC 8/2006
AND zd.div_id IN
('AB', 'AF', 'PC', 'RD', 'NV', 'VS', 'CS', 'AX',
'VC')
AND NOT EXISTS (
SELECT 1
FROM cust_hier_tab c2
WHERE c2.cust_cd = z.cust_cd
AND c2.div = zd.div_id)
ORDER BY z.sorg_cd,
z.cust_cd,
z.bunt_orig, -- ES/CS 5/2002
div,
asgn_typ,
z.to_dt DESC,
z.dflt_flag DESC,
z.from_dt DESC;
** Source records - CUSTs with both div and mpg assignments
** Used in process_new_record logic where target is read, not sequential
** 5/2002 CJL - added field bunt_orig to source tab for use in order by.
** This was necessary to allow ES PC/NV customer-territories to be written
** before VI. PC/NV team splits required division level allignments. From
** a customer not srep perspective ES territories need to take priority.
CURSOR c_mpg_and_div
IS
SELECT /*+ ALL_ROWS */
DISTINCT z.sorg_cd, z.mpg, z.bunt, --DP
z.bunt_orig, -- ES/CS 5/2002
NVL (zd.div_id, 'na') div, cust_cd, to_dt, from_dt,
cust_rgn_cd, cust_grp_cd, cust_area_cd, cust_nm,
cust_rgn_desc, cust_grp_desc, cust_area_desc, sorg_desc,
cust_ter_cd, cust_ter_desc, mkt_cd, mkt_desc,
DECODE (z.div, 'na', 'mpg', 'div') asgn_typ, dflt_flag
FROM cust_hier_tab z, zrep_mpg_div zd
WHERE sorg_cd IN ('S004', 'S096')
AND (z.mpg = zd.mpg_id OR z.div = zd.div_id)
-- Added NV, VS, CS 5/2002
-- Added AX 12/2005
-- Added VC 8/2006
AND zd.div_id IN
('AB', 'AF', 'PC', 'RD', 'NV', 'VS', 'CS', 'AX',
'VC')
AND EXISTS (
SELECT 1
FROM cust_hier_tab c2
WHERE c2.cust_cd = z.cust_cd
AND c2.div = zd.div_id)
ORDER BY z.sorg_cd,
z.cust_cd,
z.bunt_orig, -- ES/CS 5/2002
div,
asgn_typ,
z.to_dt DESC,
z.dflt_flag DESC,
z.from_dt DESC;
CURSOR c_mpg_div
IS
SELECT div_id
FROM mpg_div_s004
WHERE mpg_id = v_mpg
ORDER BY div_id;
CURSOR c_targ_dates (
p_sorg VARCHAR2,
p_cust VARCHAR2,
p_div VARCHAR2,
p_bunt VARCHAR2
) --DP
IS
-- cust_hier_key table replaced by view 5/2002
SELECT /*+ INDEX (cust_hier_pk) */
from_dt, to_dt
FROM cust_hier
WHERE sorg_cd = p_sorg
AND bunt = p_bunt --DP
AND div = p_div
AND cust_cd = p_cust
ORDER BY to_dt DESC;
TYPE t_targ_dates IS TABLE OF c_targ_dates%ROWTYPE
INDEX BY BINARY_INTEGER;
targ_tab t_targ_dates;
PROCEDURE do_insert
IS
PROCEDURE process_insert_record
IS
CURSOR c_es_div_split
IS
SELECT div_id
FROM zrep_mpg_div
WHERE div_id IN ('PC', 'BP', 'BI', 'CI', 'CR');
PROCEDURE write_record
IS
CURSOR c_plan_fields
IS
SELECT x.comp_plan_id, x.comp_plan_cd, cp.comp_plan_nm
FROM cp_div_xref@dm x, comp_plan@dm cp
WHERE x.comp_plan_id = cp.comp_plan_id
AND x.div = v_div
AND x.sorg_cd = v_sorg_cd
AND x.comp_plan_yr = TO_NUMBER (TO_CHAR (v_to_dt, 'yyyy'));
TYPE test1 IS TABLE OF c_plan_fields%ROWTYPE
INDEX BY BINARY_INTEGER;
test2 test1;
BEGIN                                                 -- write_record
OPEN c_plan_fields;
FETCH c_plan_fields bulk collect INTO test2;
CLOSE c_plan_fields;
ForAll X In 1..test2.comp_plan_id.Count+ ---------getting error here....
INSERT INTO cust_hier
*(sorg_cd, cust_cd, bunt, --DP*
div,
from_dt,
to_dt,
cust_ter_cd, cust_rgn_cd, cust_grp_cd,
cust_area_cd, sorg_desc, cust_nm, cust_ter_desc,
cust_rgn_desc, cust_grp_desc, cust_area_desc,
cust_mkt_cd, cust_mkt_desc, curr_flag,
last_mth_flag, comp_plan_id, comp_plan_cd,
comp_plan_nm, asgn_typ, lddt
*VALUES (v_sorg_cd, v_cust_cd, v_bunt,                    --DP*
v_div,
TRUNC (v_from_dt),
TO_DATE (TO_CHAR (v_to_dt, 'mmddyyyy') || '235959',
*'mmddyyyyhh24miss'*
v_ter, v_rgn, v_grp,
v_area, v_sorg_desc, v_cust_nm, v_cust_ter_desc,
v_rgn_desc, v_grp_desc, v_area_desc,
v_mkt, v_mkt_desc, v_curr_flag,
v_last_mth_flag, test2.comp_plan_id(X),test2.comp_plan_cd(X),
test2.comp_plan_nm(X)
*, v_asgn_typ, v_begin_dt*
v_plan_id := 0;
v_plan_cd := 0;
v_plan_nm := NULL;
v_out_cnt := v_out_cnt + 1;
IF doing_both
THEN
COMMIT;
ELSE
--  commiting v_commit_rows rows at a time.
IF v_out_cnt >= v_commit_cnt
THEN
COMMIT;
p.l (   'Commit point reached: '
*|| v_out_cnt*
*|| 'at: '*
*|| TO_CHAR (SYSDATE, 'mm/dd hh24:mi:ss')*
v_commit_cnt := v_commit_cnt + v_commit_rows;
END IF;
END IF;
END write_record; FUNCTION write_div
RETURN BOOLEAN
IS
return_true_false BOOLEAN;
BEGIN
IF v_to_dt < TO_DATE ('08012001', 'mmddyyyy')
AND (v_div = 'BH' OR v_div = 'TH')
THEN
-- Start of BH/TH at CRM
return_true_false := FALSE;
ELSIF v_to_dt < TO_DATE ('10012001', 'mmddyyyy') AND v_div = 'RD'
THEN
-- Start of RD at USA/VI
return_true_false := FALSE;
ELSIF v_to_dt < TO_DATE ('01012002', 'mmddyyyy')
AND (v_div = 'DD' OR v_div = 'CK')
THEN
-- Start of DD/CK at VI
return_true_false := FALSE;
ELSIF v_to_dt < TO_DATE ('12012001', 'mmddyyyy') AND v_div = 'NV'
THEN
-- Start of NV at ES
return_true_false := FALSE;
ELSIF v_to_dt < TO_DATE ('01012002', 'mmddyyyy') AND v_div = 'LP'
THEN
-- Start of LP at ES
return_true_false := FALSE;
ELSIF v_to_dt < TO_DATE ('01012003', 'mmddyyyy')
AND ( v_div = 'AN'
OR v_div = 'AX'
OR v_div = 'BT'
OR v_div = 'FB'
OR v_div = 'VH'
THEN
-- Start of AN,AX,BT,FB,VH at CS
return_true_false := FALSE;
ELSIF v_to_dt < TO_DATE ('01012005', 'mmddyyyy')
AND ( v_div = 'CR'
OR v_div = 'CI'
OR v_div = 'BP'
OR v_div = 'BI'
OR v_div = 'PM'
THEN
-- Start of CR,CI,BP,BI at ES and PM at CRM
return_true_false := FALSE;
ELSIF v_to_dt < TO_DATE ('01012005', 'mmddyyyy') AND v_div = 'VC'
THEN
-- Start of legacy VC at VI/ABT
return_true_false := FALSE;
ELSE
return_true_false := TRUE;
END IF;
RETURN return_true_false;
END write_div;
BEGIN -- process_insert_record
--p.l('Start process_insert_record');
IF v_last_day_dt BETWEEN v_from_dt AND v_to_dt
THEN
v_curr_flag := 1;
ELSE
v_curr_flag := 0;
END IF;
IF v_last_mth_dt BETWEEN v_from_dt AND v_to_dt
THEN
v_last_mth_flag := 1;
ELSE
v_last_mth_flag := 0;
END IF;
IF mpg_only
THEN
-- for each division to expand to
--p.l('Loop Bunt/MPG: ' || v_bunt || '/' || v_mpg);
FOR v_mpg_div IN c_mpg_div
LOOP
v_div := v_mpg_div.div_id;
--p.l('Div in loop: ' || v_div);
IF write_div
THEN
write_record;
END IF;
END LOOP;
--p.l('End Loop Bunt/MPG');
--p.l(' ');
ELSE
--p.l(' No Loop Bunt/MPG/div: '||v_bunt||'/'||v_mpg||'/'||v_div);
IF v_div = 'PC'
-- ES/05 split of PC division into 4 new divisions.
THEN
FOR cdiv IN c_es_div_split
LOOP
v_div := cdiv.div_id;
IF write_div
THEN
write_record;
END IF;
END LOOP;
v_div := 'PC';
ELSE
IF write_div
THEN
write_record;
END IF;
END IF;
END IF;
--p.l('End process_insert_record');
END process_insert_record;
BEGIN -- do_insert
--p.l('Sorg: ' || v_sorg_cd|| ' Cust: ' || v_cust_cd  );
--p.l(' DIV: ' || v_div||'from_dt: '||v_from_dt||' to_dt: '||v_to_dt);
v_orig_from_dt := v_from_dt;
v_orig_to_dt := v_to_dt;
v_from_yr := TO_NUMBER (TO_CHAR (v_from_dt, 'yyyy'));
v_to_yr := TO_NUMBER (TO_CHAR (v_to_dt, 'yyyy'));
v_yr_diff := v_to_yr - v_from_yr;
IF v_yr_diff = 0
THEN
process_insert_record;
END IF;
IF v_yr_diff > 0
THEN -- write first year record
v_to_dt := TO_DATE ('1231' || TO_CHAR (v_from_yr), 'mmddyyyy');
process_insert_record;
IF v_yr_diff = 1
THEN -- write 2nd year record
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 1), 'mmddyyyy');
v_to_dt := v_orig_to_dt;
process_insert_record;
ELSIF v_yr_diff = 2
THEN -- write 2nd and 3rd records
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 1), 'mmddyyyy');
v_to_dt :=
TO_DATE ('1231' || TO_CHAR (v_from_yr + 1), 'mmddyyyy');
process_insert_record;
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 2), 'mmddyyyy');
v_to_dt := v_orig_to_dt;
process_insert_record;
ELSIF v_yr_diff = 3
THEN -- write 2nd, 3rd and 4th records
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 1), 'mmddyyyy');
v_to_dt :=
TO_DATE ('1231' || TO_CHAR (v_from_yr + 1), 'mmddyyyy');
process_insert_record;
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 2), 'mmddyyyy');
v_to_dt :=
TO_DATE ('1231' || TO_CHAR (v_from_yr + 2), 'mmddyyyy');
process_insert_record;
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 3), 'mmddyyyy');
v_to_dt := v_orig_to_dt;
process_insert_record;
ELSIF v_yr_diff = 4
THEN -- write 2nd, 3rd, 4th and 5th records
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 1), 'mmddyyyy');
v_to_dt :=
TO_DATE ('1231' || TO_CHAR (v_from_yr + 1), 'mmddyyyy');
process_insert_record;
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 2), 'mmddyyyy');
v_to_dt :=
TO_DATE ('1231' || TO_CHAR (v_from_yr + 2), 'mmddyyyy');
process_insert_record;
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 3), 'mmddyyyy');
v_to_dt :=
TO_DATE ('1231' || TO_CHAR (v_from_yr + 3), 'mmddyyyy');
process_insert_record;
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 4), 'mmddyyyy');
v_to_dt := v_orig_to_dt;
process_insert_record;
ELSIF v_yr_diff = 5
THEN -- write 2nd, 3rd, 4th 5th and 6th records
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 1), 'mmddyyyy');
v_to_dt :=
TO_DATE ('1231' || TO_CHAR (v_from_yr + 1), 'mmddyyyy');
process_insert_record;
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 2), 'mmddyyyy');
v_to_dt :=
TO_DATE ('1231' || TO_CHAR (v_from_yr + 2), 'mmddyyyy');
process_insert_record;
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 3), 'mmddyyyy');
v_to_dt :=
TO_DATE ('1231' || TO_CHAR (v_from_yr + 3), 'mmddyyyy');
process_insert_record;
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 4), 'mmddyyyy');
v_to_dt :=
TO_DATE ('1231' || TO_CHAR (v_from_yr + 4), 'mmddyyyy');
process_insert_record;
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 5), 'mmddyyyy');
v_to_dt := v_orig_to_dt;
process_insert_record;
ELSIF v_yr_diff = 6
THEN -- write 2nd, 3rd, 4th 5th 6th 7th records
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 1), 'mmddyyyy');
v_to_dt :=
TO_DATE ('1231' || TO_CHAR (v_from_yr + 1), 'mmddyyyy');
process_insert_record;
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 2), 'mmddyyyy');
v_to_dt :=
TO_DATE ('1231' || TO_CHAR (v_from_yr + 2), 'mmddyyyy');
process_insert_record;
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 3), 'mmddyyyy');
v_to_dt :=
TO_DATE ('1231' || TO_CHAR (v_from_yr + 3), 'mmddyyyy');
process_insert_record;
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 4), 'mmddyyyy');
v_to_dt :=
TO_DATE ('1231' || TO_CHAR (v_from_yr + 4), 'mmddyyyy');
process_insert_record;
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 5), 'mmddyyyy');
v_to_dt :=
TO_DATE ('1231' || TO_CHAR (v_from_yr + 5), 'mmddyyyy');
process_insert_record;
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 6), 'mmddyyyy');
v_to_dt := v_orig_to_dt;
process_insert_record;
ELSIF v_yr_diff = 7
THEN -- write 2nd, 3rd, 4th 5th 6th 7th 8th records
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 1), 'mmddyyyy');
v_to_dt :=
TO_DATE ('1231' || TO_CHAR (v_from_yr + 1), 'mmddyyyy');
process_insert_record;
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 2), 'mmddyyyy');
v_to_dt :=
TO_DATE ('1231' || TO_CHAR (v_from_yr + 2), 'mmddyyyy');
process_insert_record;
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 3), 'mmddyyyy');
v_to_dt :=
TO_DATE ('1231' || TO_CHAR (v_from_yr + 3), 'mmddyyyy');
process_insert_record;
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 4), 'mmddyyyy');
v_to_dt :=
TO_DATE ('1231' || TO_CHAR (v_from_yr + 4), 'mmddyyyy');
process_insert_record;
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 5), 'mmddyyyy');
v_to_dt :=
TO_DATE ('1231' || TO_CHAR (v_from_yr + 5), 'mmddyyyy');
process_insert_record;
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 6), 'mmddyyyy');
v_to_dt :=
TO_DATE ('1231' || TO_CHAR (v_from_yr + 6), 'mmddyyyy');
-- v_to_dt := v_orig_to_dt; -- Todd: this is wrong, I commented it out.
process_insert_record;
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 7), 'mmddyyyy');
v_to_dt := v_orig_to_dt;
process_insert_record;
ELSIF v_yr_diff = 8
THEN -- write 2nd, 3rd, 4th 5th 6th 7th 8th 9th records
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 1), 'mmddyyyy');
v_to_dt :=
TO_DATE ('1231' || TO_CHAR (v_from_yr + 1), 'mmddyyyy');
process_insert_record;
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 2), 'mmddyyyy');
v_to_dt :=
TO_DATE ('1231' || TO_CHAR (v_from_yr + 2), 'mmddyyyy');
process_insert_record;
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 3), 'mmddyyyy');
v_to_dt :=
TO_DATE ('1231' || TO_CHAR (v_from_yr + 3), 'mmddyyyy');
process_insert_record;
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 4), 'mmddyyyy');
v_to_dt :=
TO_DATE ('1231' || TO_CHAR (v_from_yr + 4), 'mmddyyyy');
process_insert_record;
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 5), 'mmddyyyy');
v_to_dt :=
TO_DATE ('1231' || TO_CHAR (v_from_yr + 5), 'mmddyyyy');
process_insert_record;
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 6), 'mmddyyyy');
v_to_dt :=
TO_DATE ('1231' || TO_CHAR (v_from_yr + 6), 'mmddyyyy');
process_insert_record;
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 7), 'mmddyyyy');
v_to_dt :=
TO_DATE ('1231' || TO_CHAR (v_from_yr + 7), 'mmddyyyy');
process_insert_record;
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 8), 'mmddyyyy');
v_to_dt := v_orig_to_dt;
process_insert_record;
ELSIF v_yr_diff = 9
THEN -- write 2nd, 3rd, 4th 5th 6th 7th 8th 9th 10th records
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 1), 'mmddyyyy');
v_to_dt :=
TO_DATE ('1231' || TO_CHAR (v_from_yr + 1), 'mmddyyyy');
process_insert_record;
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 2), 'mmddyyyy');
v_to_dt :=
TO_DATE ('1231' || TO_CHAR (v_from_yr + 2), 'mmddyyyy');
process_insert_record;
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 3), 'mmddyyyy');
v_to_dt :=
TO_DATE ('1231' || TO_CHAR (v_from_yr + 3), 'mmddyyyy');
process_insert_record;
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 4), 'mmddyyyy');
v_to_dt :=
TO_DATE ('1231' || TO_CHAR (v_from_yr + 4), 'mmddyyyy');
process_insert_record;
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 5), 'mmddyyyy');
v_to_dt :=
TO_DATE ('1231' || TO_CHAR (v_from_yr + 5), 'mmddyyyy');
process_insert_record;
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 6), 'mmddyyyy');
v_to_dt :=
TO_DATE ('1231' || TO_CHAR (v_from_yr + 6), 'mmddyyyy');
process_insert_record;
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 7), 'mmddyyyy');
v_to_dt :=
TO_DATE ('1231' || TO_CHAR (v_from_yr + 7), 'mmddyyyy');
process_insert_record;
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 8), 'mmddyyyy');
v_to_dt :=
TO_DATE ('1231' || TO_CHAR (v_from_yr + 8), 'mmddyyyy');
process_insert_record;
v_from_dt :=
TO_DATE ('0101' || TO_CHAR (v_from_yr + 9), 'mmddyyyy');
v_to_dt := v_orig_to_dt;
process_insert_record;
ELSE -- abend with error
p.l ('End year: ' || v_to_yr || ' is greater than 2007');
raise_application_error (-20001, 'End Year greater than 2007');
END IF;
END IF;
v_from_dt := v_orig_from_dt;
v_to_dt := v_orig_to_dt;
END do_insert;
PROCEDURE save_source -- save source in global variables
IS
BEGIN
v_sorg_cd := src_rec.sorg_cd;
v_cust_cd := src_rec.cust_cd;
v_mpg := src_rec.mpg;
v_bunt := src_rec.bunt; --DP
v_div := src_rec.div;
v_from_dt := src_rec.from_dt;
v_to_dt := src_rec.to_dt;
v_from_dt_orig := src_rec.from_dt;
v_to_dt_orig := src_rec.to_dt;
v_ter := src_rec.cust_ter_cd;
v_rgn := src_rec.cust_rgn_cd;
v_grp := src_rec.cust_grp_cd;
v_area := src_rec.cust_area_cd;
v_sorg_desc := src_rec.sorg_desc;
v_cust_nm := src_rec.cust_nm;
v_cust_ter_desc := src_rec.cust_ter_desc;
v_rgn_desc := src_rec.cust_rgn_desc;
v_grp_desc := src_rec.cust_grp_desc;
v_area_desc := src_rec.cust_area_desc;
v_mkt := src_rec.mkt_cd;
v_mkt_desc := src_rec.mkt_desc;
v_asgn_typ := src_rec.asgn_typ;
v_prev_values := v_ter || v_rgn || v_grp || v_area;
END save_source;
PROCEDURE clear_keys -- clear key fields
IS
BEGIN
v_sorg_cd := NULL;
v_cust_cd := NULL;
v_mpg := NULL;
v_bunt := NULL;
v_div := NULL;
v_from_dt := NULL;
v_to_dt := NULL;
v_from_dt_orig := NULL;
v_to_dt_orig := NULL;
END clear_keys;
PROCEDURE fill_targ_tab (
sorg_in IN cust_hier.sorg_cd%TYPE,
cust_in IN cust_hier.cust_cd%TYPE,
div_in IN cust_hier.div%TYPE,
bunt_in IN cust_hier.bunt%TYPE --DP
IS
BEGIN
targ_tab.DELETE;
no_targ_found := TRUE;
last_targ := 0;
FOR targ_dates_rec IN c_targ_dates (sorg_in, cust_in, div_in, bunt_in)
--DP
LOOP
--p.l('Found a targ record');
no_targ_found := FALSE;
v_next_row := NVL (targ_tab.LAST, 0) + 1;
targ_tab (v_next_row) := targ_dates_rec;
END LOOP;
last_targ := targ_tab.LAST;
END fill_targ_tab;
PROCEDURE process_new_record
IS
BEGIN
** Put all existing target records for given sorg,
** cust and div in a PL/SQL table
fill_targ_tab (v_sorg_cd, v_cust_cd, v_div, v_bunt); --DP
IF no_targ_found
THEN
--p.l ('1-no_targ_found after looking for ' || v_div);
do_insert;
ELSE -- possibly add but do not over-ride
last_rec := FALSE;
FOR i IN 1 .. last_targ
LOOP
IF i = last_targ
THEN
--p.l ('2-This is the last targ rec in pl/sql tab');
last_rec := TRUE; -- just for readability later
END IF;
t_from_dt := targ_tab (i).from_dt;
t_to_dt := targ_tab (i).to_dt;
--p.l ('3-Executed tab loop ' || i || ' times.');
--p.l ('3-targ rec start: ' || t_from_dt || 'targ rec end  : ' || t_to_dt);
IF v_to_dt > t_to_dt
THEN
--p.l ('4-when src_end is after targ_end = always an insert' );
IF v_from_dt > t_to_dt
THEN
--p.l ('5-when src_st after targ_end, insert');
do_insert;
EXIT;
ELSIF v_from_dt >= t_from_dt
THEN
--p.l ('6-when s_st is at or after targ_st, insert src');
--p.l ('6-after targ by setting the new s_st date');
v_from_dt := TRUNC (t_to_dt) + 1;
do_insert;
EXIT;
ELSE
--p.l ('7-when src_st is before targ_st, insert src after targ');
--p.l ( '7-then look to see if src can be added after targ' );
v_from_dt := TRUNC (t_to_dt) + 1;
do_insert;
--write_dup := FALSE;
v_to_dt := TRUNC (t_from_dt) - 1 / (24 * 60 * 60);
v_from_dt := v_from_dt_orig;
IF last_rec
THEN
--p.l ( '8-when this is last targ, insert after targ' );
do_insert;
-- naturally exits with last_rec
ELSE
--p.l ('9-when not last targ rec, get another one');
NULL;
END IF;
END IF;
ELSIF v_from_dt >= t_from_dt
THEN
--p.l ('10-s_from >= t_from and s_to < t_to == contained/dup');
--do_dup_insert;
EXIT;
ELSE
--p.l ('15-s_from < t_from and s_to <= t_to');
IF v_to_dt >= t_from_dt
THEN
--p.l ('16-src is before targ, adjust s_to');
v_to_dt := TRUNC (t_from_dt) - 1 / (24 * 60 * 60);
IF last_rec
THEN
--p.l ('19-when last targ rec, insert');
do_insert;
-- naturally exits with last_rec
ELSE
--p.l ('20-when more targ, get another, look for end');
NULL;
END IF;
ELSE
--p.l ('21-src_from and src_to < t_from');
IF last_rec
THEN
--p.l ('22-when last targ rec, insert');
do_insert;
-- naturally exits with last_rec
ELSE
--p.l ( '23-when more targ recs, targ could still fit' );
NULL;
END IF;
END IF;
END IF; -- starting if
END LOOP; -- targ_tab loop
END IF; -- no_dirs_found
END process_new_record;
BEGIN
-- Initialize meta data variables
v_begin_dt := SYSDATE;
v_in_cnt := 0;
v_out_cnt := 0;
** Get dates for last end of busines day and last closed month
SELECT d_val
INTO v_last_day_dt
FROM gp_parms
WHERE KEY = 'end_of_business' AND parm = 'day';
SELECT d_val
INTO v_last_mth_dt
FROM gp_parms
WHERE KEY = 'end_of_business' AND parm = 'month';
p.l (' ');
p.l ('End of business day is: ' || TO_CHAR (v_last_day_dt, 'mm/dd/yyyy'));
p.l ('End of business month is: ' || TO_CHAR (v_last_mth_dt, 'mm/dd/yyyy'));
p.l (' ');
-- DELETE RECORDS THAT ARE CURRENTLY IN THE TARGET TABLE
truncate_table ('cust_hier');
p.l ('Table cust_hier truncated.');
-- Create the default record
INSERT INTO cust_hier
(sorg_cd, bunt, --DP
div, from_dt,
to_dt, cust_cd, cust_ter_cd,
cust_rgn_cd, cust_grp_cd, cust_area_cd, cust_nm,
cust_ter_desc, cust_rgn_desc, cust_grp_desc, cust_area_desc,
sorg_desc, cust_mkt_cd, cust_mkt_desc, comp_plan_id,
comp_plan_cd, comp_plan_nm, curr_flag, last_mth_flag,
asgn_typ, lddt
VALUES ('S004', 'na', --DP
'na', TO_DATE ('01011900', 'mmddyyyy'),
TO_DATE ('12319999235959', 'mmddyyyyhh24miss'), 'na', 'na',
'na', 'na', 'na', 'Not Known',
'Not Known', 'Not Known', 'Not Known', 'Not Known',
'US Sales Org', 'USA', 'United States', 0,
'na', 'Missing', 1, 1,
'div', SYSDATE
COMMIT;
doing_both := TRUE;
mpg_only := FALSE;
p.l ( 'Start CUSTs with both MPG and DIV assignments at: '
|| TO_CHAR (SYSDATE, 'mm/dd/yyyy hh24:mi:ss')
p.l (' ');
** Process AB AF PC RD Divisions for customers with MPG and DIV assignments
** Added NV and VS, CS 5/2002.
** Added AX 12/2005
** Added VC 8/2006
first_rec := TRUE;
clear_keys;
OPEN c_mpg_and_div;
LOOP
FETCH c_mpg_and_div
INTO src_rec;
EXIT WHEN c_mpg_and_div%NOTFOUND;
v_in_cnt := v_in_cnt + 1;
--write_dup := TRUE;
save_source;
process_new_record;
END LOOP;
COMMIT;
CLOSE c_mpg_and_div;
p.l ( 'Customers with both MPG and DIV assignments done: '
|| TO_CHAR (SYSDATE, 'mm/dd/yyyy hh24:mi:ss')
p.l ('Input records: ' || v_in_cnt || ', Output records: ' || v_out_cnt);
v_tot_in := v_tot_in + v_in_cnt;
v_tot_out := v_tot_out + v_out_cnt;
v_in_cnt := 0;
v_out_cnt := 0;
p.l ( 'Total Input records: '
|| v_tot_in
|| ', Total Output records: '
|| v_tot_out
p.l ('Input/Output ratio: ' || TO_CHAR (v_tot_in / v_tot_out, '999.99'));
p.l (' ');
** Start of MPG only processing, sequential without read of target
doing_both := FALSE;
mpg_only := FALSE;
p.l (' ');
p.l ( 'Start sequencial loop processing at: '
|| TO_CHAR (SYSDATE, 'mm/dd/yyyy hh24:mi:ss')
** Process AB AF PC RD Divisions for customers with only MPG assignments
** Added NV and VS, CS 5/2002.
** Added AX 12/2005
** Added VC 8/2006
first_rec := TRUE;
clear_keys;
OPEN c_div_only_mpg;
LOOP
FETCH c_div_only_mpg
INTO src_rec;
-- Process last record
IF c_div_only_mpg%NOTFOUND AND NOT first_rec
THEN
do_insert;
END IF;
EXIT WHEN c_div_only_mpg%NOTFOUND;
v_in_cnt := v_in_cnt + 1;
IF src_rec.sorg_cd = v_sorg_cd --src_key = prev_key
AND src_rec.cust_cd = v_cust_cd
AND src_rec.bunt = v_bunt --DP
AND src_rec.div = v_div
THEN
--p.l ('S1-same key, looking for same hierarchy');
v_src_values :=
src_rec.cust_ter_cd
|| src_rec.cust_rgn_cd
|| src_rec.cust_grp_cd
|| src_rec.cust_area_cd;
IF v_src_values = v_prev_values
THEN
--p.l ( 'S2-same key and hierarchy' );
IF src_rec.from_dt <= v_from_dt
THEN
--p.l( 'S3-if src from_dt is earlier, use it' );
v_from_dt := src_rec.from_dt;
END IF;
ELSE
p.l ( 'S4 same key but new hierarchy, check date' );
--p.l ( 'S4 S_from_dt: ' || src_rec.from_dt ||
-- ' V_from_dt: ' || v_from_dt);
--insert only when src from_dt is earlier even if hier has changed
IF src_rec.from_dt < v_from_dt
THEN
--p.l ('S5-Insert previous and save source');
do_insert;
-- set source rec to_dt to be just prior to previous rec from_dt
-- this enforces contiguous allignments (no time overlaps)
src_rec.to_dt := TRUNC (v_from_dt) - 1 / (24 * 60 * 60);
save_source;
END IF;
END IF;
ELSE
--p.l ( 'S6- New Key' );
IF first_rec
THEN
first_rec := FALSE;
ELSE
--p.l( 'S7- Inserting previous record' );
do_insert;
END IF;
save_source;
END IF; -- src_key = prev_key
END LOOP; -- rec in c_div_only_mpg cursor loop
COMMIT;
CLOSE c_div_only_mpg;
p.l ( 'Division assign. Customers with only MPG assign. done: '
|| TO_CHAR (SYSDATE, 'mm/dd/yyyy hh24:mi:ss')
p.l ('Input records: ' || v_in_cnt || ', Output records: ' || v_out_cnt);
v_tot_in := v_tot_in + v_in_cnt;
v_tot_out := v_tot_out + v_out_cnt;
v_in_cnt := 0;
v_out_cnt := 0;
p.l ( 'Total Input records: '
|| v_tot_in
|| ', Total Output records: '
|| v_tot_out
p.l ('Input/Output ratio: ' || TO_CHAR (v_tot_in / v_tot_out, '999.99'));
p.l (' ');
** Process pure MPG assignments
doing_both := FALSE;
mpg_only := TRUE;
first_rec := TRUE;
clear_keys;
OPEN c_mpg;
LOOP
FETCH c_mpg
INTO src_rec;
-- Process last record
IF c_mpg%NOTFOUND AND NOT first_rec
THEN
do_insert;
END IF;
EXIT WHEN c_mpg%NOTFOUND;
v_in_cnt := v_in_cnt + 1;
** Troubleshooting
p.l('New record');
p.l('V sorg/cust/bunt: ' || v_sorg_cd || v_cust_cd || v_bunt);
p.l('S sorg/cust/bunt: ' || src_rec.sorg_cd || src_rec.cust_cd ||
src_rec.bunt);
p.l(' ');
IF src_rec.sorg_cd = v_sorg_cd --src_key = prev_key
AND src_rec.cust_cd = v_cust_cd
AND src_rec.mpg = v_mpg
THEN
--p.l ('MS1-same key, looking for same hierarchy');
v_src_values :=
src_rec.cust_ter_cd
|| src_rec.cust_rgn_cd
|| src_rec.cust_grp_cd
|| src_rec.cust_area_cd;
IF v_src_values = v_prev_values
THEN
--p.l ( 'MS2-same key and hierarchy' );
IF src_rec.from_dt <= v_from_dt
THEN
--p.l( 'MS3-if src from_dt is earlier, use it' );
v_from_dt := src_rec.from_dt;
END IF;
ELSE
p.l ( 'MS4 same key but new hierarchy, check date' );
--p.l ( 'MS4 S_from_dt: ' || src_rec.from_dt ||
-- ' V_from_dt: ' || v_from_dt);
--insert only when src from_dt is earlier even if hier has changed
IF src_rec.from_dt < v_from_dt
THEN
--p.l ('MS5-Insert previous and save source');
do_insert;
-- set source rec to_dt to be just prior to previous rec from_dt
-- this enforces contiguous allignments (no time overlaps)
src_rec.to_dt := TRUNC (v_from_dt) - 1 / (24 * 60 * 60);
save_source;
END IF;
END IF;
ELSE
--p.l ( 'MS6- New Key' );
IF first_rec
THEN
first_rec := FALSE;
--p.l('First record in c_mpg cursor detected');
ELSE
--p.l( 'MS7- Inserting previous record' );
do_insert;
END IF;
save_source;
END IF; -- src_key = prev_key
END LOOP; -- rec in c_mpg cursor loop
COMMIT;
CLOSE c_mpg;
mpg_only := FALSE;
p.l ( 'Customers with only MPG assignments done: '
|| TO_CHAR (SYSDATE, 'mm/dd/yyyy hh24:mi:ss')
p.l ('Input records: ' || v_in_cnt || ', Output records: ' || v_out_cnt);
p.l (' ');
v_tot_in := v_tot_in + v_in_cnt;
v_tot_out := v_tot_out + v_out_cnt;
p.l ( 'Total Input records: '
|| v_tot_in
|| ', Total Output records: '
|| v_tot_out
p.l ( 'Analyze tables started: '
|| TO_CHAR (SYSDATE, 'mm/dd/yyyy hh24:mi:ss')
atab ('cust_hier');
v_end_dt := SYSDATE;
p.l (' ');
p.l ('Finished at: ' || TO_CHAR (v_end_dt, 'mm/dd/yyyy hh24:mi:ss'));
EXCEPTION
WHEN NO_DATA_FOUND
THEN
v_error_code := SQLCODE;
v_error_message := SUBSTR (SQLERRM, 1, 200);
p.l ('Failure during end of business date processing');
p.l ('ERROR : ' || v_error_message);
raise_application_error (-20001, v_error_message);
WHEN OTHERS
THEN
v_error_code := SQLCODE;
v_error_message := SUBSTR (SQLERRM, 1, 200);
p.l ('Error: ' || v_error_message);
p.l ('Sorg: ' || v_sorg_cd || ' CUST: ' || v_cust_cd);
p.l ( ' DIV: '
|| v_div
|| ' BUNT: '
|| v_bunt
|| ' from_dt: '
|| v_from_dt
|| ' to_dt: '
|| v_to_dt
); --DP
p.l ( 'v_from: '
|| v_from_dt
|| ' v_to: '
|| v_to_dt
|| ' v_pcd: '
|| v_plan_cd
p.l ( 'o_from: '
|| v_orig_from_dt
|| ' o_to: '
|| v_orig_to_dt
|| ' fyr: '
|| v_from_yr
|| ' tyr: '
|| v_to_yr
|| ' yr_dif: '
|| v_yr_diff
raise_application_error (-20001, v_error_message);
END;
/

Similar Messages

  • Presentation variable is not supported in "SQL Issued"

    hi, there is a presentation variable called @{ps_var} from a prompt
    and I have written a custom sql and typed in "SQL Issued"
    !http://img31.imageshack.us/img31/8673/customsql.jpg!
    I found that the presentation variable is not supported in "SQL Issued" (exception flows when I clicked the "Set SQL" button.)
    (in the captured screen, it is hardcoded as 'REPLACED_BY_PRESENTATION_VARIABLE', no error occurs when I clicked the "Set SQL" button. the result is correct.
    however, when 'REPLACED_BY_PRESENTATION_VARIABLE' is replaced by @{ps_var}, exception flows when I clicked the "Set SQL" button.
    is there an alternatives to avoid the error ? or any ways to assign the selected value from the prompt to this sql ?
    thank you very much!

    Just set your presentation variable with an other method.
    Check here you will find how you can set a presentation variable for a filter
    http://gerardnico.com/wiki/dat/obiee/presentation_service/obiee_presentation_variable_area

  • Set filter (with presentation variables) for requests using "SQL Issued"

    if I have a "SQL issued":
    SELECT saw_0 saw_0, saw_1 saw_1, saw_2 saw_2, saw_3 saw_3, saw_4 saw_4 FROM (
    SELECT saw_0 saw_0, saw_1 saw_1, SUM(saw_2) saw_2, SUM(saw_3) saw_3, SUM(saw_4) saw_4
    FROM
    SELECT "Period"."YearMonth" saw_0, "Customer"."CustomerName" saw_1, COUNT("Sales"."SalesDate") saw_2, "Sales"."No.OfConsumer" saw_3, 0 saw_4
    FROM CRM
    WHERE ("Period"."YearMonth" >= 200904) AND ("Period"."YearMonth" <= 200910)
    UNION ALL
    SELECT "Period"."YearMonth" saw_0, "Customer"."CustomerName" saw_1, 0 saw_2, 0 saw_3, Count("SuperSales"."SuperSalesDate") saw_4
    FROM CRM
    WHERE ("Period"."YearMonth" >= 200904) AND ("Period"."YearMonth" <= 200910)
    ) t1
    GROUP BY saw_0, saw_1
    ORDER BY saw_0, saw_1
    ) t2 ORDER BY saw_0
    actually, in this request, I would like to set a filter for "Period"."YearMonth" using presentation variable.
    is it possible to do this ?
    Thanks !!

    Hi Forreging,
    You can use presentation variables, but not if you are directly setting the SQL via the Advanced tab.
    Instead, build up the first report just like the first part of the UNION statement. Then use the "Combine with Similar request" to build up the logic for the second part of the query.
    When you approach it this way, you have the ability to set filters on each "Sub-Request" via the Criteria tab. Otherwise, OBIEE only lets you add a filter at the outer level of the query when you go the route of setting the SQL in the Advanced tab.
    Good luck and if you find this post useful, please award points!
    Best regards,
    -Joe

  • Using substitution variable in sql -- Issue

    Hello All
    I am trying to do a sql operation from command prompt of my system and that sql requires substitution variable which i am passing it but when i pass the variable ( there are two) the first one assign as " \c" and second gets both what i am passing.
    I am not sure what exactly happening here, i have done this on AIX but here its not working any ideas?
    System : uname -a
    Linux ## 2.6.18-128.1.1.el5 #1 SMP Mon Jan 26 13:58:24 EST 2009 x86_64 x86_64 x86_64 GNU/Linux

    AIX and Linux are not the same. An output of "\c" may indicate a compatibility issue of your shell script with your current command line interpreter (shell). A \c can be used to suppress a newline with the echo command. Bash understands both formats echo -n and echo \c, but other shells like Ksh don't. Try to run your script under a Bash, which is the default under Linux. If the problem persists you will need to post your script for any further analysis.

  • SQL Issue with MS Access

    Hello;
    I have an SQL query:
    Select year, sum(group1) as A from table1 where name in ('test1', 'test2') group by year;
    When I run it through SQL editor in MS Access it returns the years and sum and a total of 5 rows.
    When I pass this command through Java: Connection.createStatement and executeQuery
    I can print the values and it prints 5 rows but after printing it hangs.
    When i get the size of result set :
    while(rs.next())
    resultSetSize ++;
    System.out.println(rs.getInt(1) + "\t" +resultSetSize);
    It shows the result set as size of 10, when i print the values it stops at 5. I am not sure where the issue is.
    I think since my where condition is have 2 values it might be causing problem.
    If I just put 1 value after my where condition, then the java code runs fine.
    Can anyone tell me what the issue is here or where am I going wrong?
    Thanks for your help.
    Edited by: yesmein on Apr 23, 2009 5:58 AM

    Thanks for the suggestion. I checked the code. Indeed I was not printing an exception. When I printed the exception this is what i get:
    Exception is: java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor state
    hope this helps to guide me on how to solve this issue.
    Below is the code:
    public static void TestQuery()
    String query="SELECT year, sum(group1) as A FROM table1 WHERE name in ('test1', 'test2') ";
    Connection conn = ConnectDB1.getDBConnection(); //this gets the database parameters from a properties file
    Statement stat = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
    ResultSet rs = stat.executeQuery(query);
    int resultSetSize=0;
    while(rs.next())
    resultSetSize ++;
    System.out.println(rs.getInt(1) + "\t" +resultSetSize);
    rs.beforeFirst();
    System.out.println("Size of result set: " +resultSetSize);
    while(rs.next())
    System.out.println(rs.getInt(1) + "\t" + rs.getInt(2) );
    rs.close();
    stat.close();
    conn.close();
    System.out.println("End of program");
    catch (Exception e){System.out.println("Exception is: " +e);}
    }

  • Show SQL issue on Posting Date and Aging Date

    Hi Folks,
    When I am running a report >>> the report pops up with the some parmeters >>
    In my scenario u201CAging Dateu201D forumla is calculated as the last day of the every month.
    if month (currentdate) = 1 then date((year(CurrentDate)-1),12,31) else
    date(year(currentdate),month(CurrentDate),1)-1
    Example : if 9( 23 sep 2010 ) = 1 then date ((2010(23 Sep 2010)-1),12,31) else date(2010(23 sep 2010),9( 23 Sep 2010),1)-1.
    Issues :
    For some reports the Aging Date parameter is poping up but for some of the reports the Aging Date forumla is calculating in the behind based on the u201CPost Dateu201D.
    Here is my Record Selection :
    (not isnull({CLARITY_TDL.SERV_AREA_ID}) and {CLARITY_TDL.SERV_AREA_ID}
    in {?Service Area} or 0 in {?Service Area}) and
    (not isnull({CLARITY_DEP.SPECIALTY}) and {CLARITY_DEP.SPECIALTY} in {?Specialty} or {?Specialty} =
    "Specialty(s)" or {?Specialty} = "NONE") and
    (not isnull({CLARITY_TDL.PERFORMING_PROV_ID}) and {CLARITY_TDL.PERFORMING_PROV_ID} in {?Service Provider} or
    {?Service Provider} = "Provider(s)" or {?Service Provider} = "NONE") and
    {CLARITY_TDL.POST_DATE} = {@Aging Date}and
    [color=darkred]{CLARITY_TDL.DETAIL_TYPE} in [60, 61] and
    {CL_EMP_CLARITY.USER_ID} = CurrentCEUserName
    Moreover when I check Show SQL for the where clause
    CLARITY_TDL"."SERV_AREA_ID" IS NOT NULL AND "CLARITY_TDL"."SERV_AREA_ID"=10 AND "CLARITY_TDL"."POST_DATE">={ts '2010-08-31 00:00:00'} AND "CLARITY_TDL"."POST_DATE"<{ts '2010-09-01 00:00:00'})
    AND ("CLARITY_TDL"."DETAIL_TYPE"=60 OR "CLARITY_TDL"."DETAIL_TYPE"=61) AND "CL_EMP_CLARITY"."USER_ID"=''
    I donu2019t know why the post date is going in between the date/time ranges. I am scrating my head to understand the things to work. Please help me out.

    Not sure what you are trying to do here
    (not isnull({CLARITY_TDL.SERV_AREA_ID}) and {CLARITY_TDL.SERV_AREA_ID}
    in {?Service Area} or 0 in {?Service Area}) and
    (not isnull({CLARITY_DEP.SPECIALTY}) and {CLARITY_DEP.SPECIALTY} in {?Specialty} or {?Specialty} =
    "Specialty(s)" or {?Specialty} = "NONE") and
    (not isnull({CLARITY_TDL.PERFORMING_PROV_ID}) and {CLARITY_TDL.PERFORMING_PROV_ID} in {?Service Provider} or
    {?Service Provider} = "Provider(s)" or {?Service Provider} = "NONE") and
    Probably better to right these on these lines
    (If {?Service Area} not equals 0 then not isnull({CLARITY_TDL.SERV_AREA_ID}) and {CLARITY_TDL.SERV_AREA_ID}
    in {?Service Area}  else true) and
    NB Typed not equals as symbols disappear
    This means nothing in SQL and will cause whole clause to be evaluated locally and not on database
    or {?Specialty} =
    "Specialty(s)" or {?Specialty} = "NONE")
    I am not sure what you are trying to do so can not offer an alternative.
    Ian

  • SQL Issue

    I have a problem with my SQL, it will return values if I
    submit nothing into my searchbox or it will find one matching value
    and display results for that, I would like a match for exact search
    values, mainly on price.
    Also is there a way I can dynamically display a drop down box
    with different values to the one I already have?
    // define an array of acceptable property types
    $propTypes = array('Houses', 'Flats/Apartments',
    'Bungalows','Commercial');
    // if submitted value is in the array of acceptable types,
    use it
    // otherwise, use a wildcard character
    if (isset($_REQUEST['PropType']) &&
    in_array($_REQUEST['PropType'], $propTypes)) {
    $PropType = "= '".$_REQUEST['PropType']."'";
    } else {
    $PropType = "LIKE '%'";
    // check that the number of bedrooms is a number
    // if it's zero, search for all numbers
    if (isset($_REQUEST['NoBeds']) &&
    is_numeric($_REQUEST['NoBeds']) &&
    $_REQUEST['NoBeds'] == 0) {
    $NoBeds = '> 0';
    } elseif (isset($_REQUEST['NoBeds']) &&
    is_numeric($_REQUEST['NoBeds']) &&
    $_REQUEST['NoBeds'] > 0) {
    $NoBeds = '= '.$_REQUEST['NoBeds'];
    } else {
    $NoBeds = '> 0';
    // if minPrice is not a number, set it to zero
    // otherwise, use the submitted value
    if (isset($_REQUEST['minPrice']) &&
    !is_numeric($_REQUEST['minPrice']) ||
    !isset($_REQUEST['minPrice'])) {
    $minPrice = 0;
    } elseif (isset($_REQUEST['minPrice']) &&
    is_numeric($_REQUEST['minPrice'])) {
    $minPrice = $_REQUEST['minPrice'];
    // if maxPrice is not a number, set it to 100 million
    // otherwise, use the submitted value
    if (isset($_REQUEST['maxPrice']) &&
    !is_numeric($_REQUEST['maxPrice']) ||
    !isset($_REQUEST['maxPrice'])) {
    $minPrice = 100000000;
    } elseif (isset($_REQUEST['maxPrice']) &&
    is_numeric($_REQUEST['maxPrice'])) {
    $minPrice = $_REQUEST['maxPrice'];
    mysql_select_db($database_db, $db);
    $query_Recordset1 = "SELECT * FROM property WHERE B_R =
    '$_POST[B_R]' AND Accepted = 'Yes' AND
    (City = '$_POST
    quote:
    ') Or Postcode LIKE '%$q' Or Area = '$_POST
    quote:
    ' AND
    PropType $PropType AND NoBeds $NoBeds AND Country = 'UK' AND
    Cost BETWEEN $minPrice AND $maxPrice ORDER BY Cost $sort";
    $Recordset1 = mysql_query($query_Recordset1, $db) or
    die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($Recordset1);

    Ok, So are you able to ping the remote SQL Server from your development machine .
    I think this issue is related to connectivity from BizTalk to SQL Server .
    Open the command prompt and try pinging the server and also check DTC configuraton .
    Thanks
    Abhishek

  • SQL: Issue with running out of storage on server when running table-valued function

    SQL Version: 2008 (not r2)
    Problem:  I'm getting the following error message when running a table-valued function:
    Msg 1105, Level 17, State 2, Line 1
    Could not allocate space for object 'dbo.SORT temporary run storage:  141072001204224' in database 'tempdb' because the 'PRIMARY' filegroup is full. Create disk space by deleting unneeded files, dropping objects in the filegroup, adding additional files
    to the filegroup, or setting autogrowth on for existing files in the filegroup.
    Request:  Could anyone tell me if there are modifications that I could make to my SQL code to avoid this storage issues?
    Thanks,
    ....bob sutor
    Code Facts:
    The JCCD table is a large table 2MM records
    The other tables in the JOINS are very small 15 records or less
    SQL Function Code:
    ALTER FUNCTION [dbo].[xcft_XAWP_GLBalance_JCCD_Detail]()
    RETURNS @JCGLDetail TABLE
          JCCo tinyint
        , Job varchar(10)
        , PostingSource varchar(10)
        , CostToDate numeric(12,2)
        , Phase varchar(20)
        , EarnType smallint
        , LiabilityType smallint
        , CostType tinyint
        , ControllingSetting varchar(30)
        , GLAccountCharged varchar(20)
        , DeptNum varchar(10)
        , DeptDesc varchar(30)
        , JCDC_CostType tinyint
        , CostTypeGL_Open varchar(20)
        , CostTypeGL_Closed varchar(20)
        , JCDO_ExcludePR varchar(1)
        , JCDO_Phase varchar(20)
        , PhaseGL_Open varchar(20)
        , PhaseGL_Closed  varchar(20)
        , JCDL_LiabType smallint
        , LiabTypeGL_Open varchar(20)
        , LiabTypeGL_Closed varchar(20)
        , JCDE_EarnType smallint
        , EarnTypeGL_Open varchar(20)
        , EarnTypeGL_Closed varchar(20)
    AS
    BEGIN
     DECLARE
     @WIPMonthCurrent date
     SET @WIPMonthCurrent = (Select TOP 1 WIPMonth FROM udxcWIPMonths WHERE ActiveWIPPeriod = 'Y')
     INSERT INTO @JCGLDetail
          JCCo
        , Job
        , PostingSource
        , CostToDate
        , Phase
        , EarnType
        , LiabilityType
        , CostType
        , DeptNum
        , DeptDesc
        , JCDC_CostType
        , CostTypeGL_Open
        , CostTypeGL_Closed
        , JCDO_ExcludePR
        , JCDO_Phase
        , PhaseGL_Open
        , PhaseGL_Closed
        , JCDL_LiabType
        , LiabTypeGL_Open
        , LiabTypeGL_Closed
        , JCDE_EarnType
        , EarnTypeGL_Open
        , EarnTypeGL_Closed
     SELECT  
         JCCD.JCCo, JCCD.Job, JCCD.Source, sum(JCCD.ActualCost) AS CostToDate, JCCD.Phase, JCCD.EarnType, JCCD.LiabilityType, JCCD.CostType
       , JCDM.Department, JCDM.Description
       , JCDC.CostType AS JCDC_CostType, JCDC.OpenWIPAcct AS CostTypeGL_Open, JCDC.ClosedExpAcct AS CostTypeGL_Closed
       , JCDO.ExcludePR AS JCDO_ExcludePR, JCDO.Phase AS JCDO_Phase, JCDO.OpenWIPAcct AS PhaseGL_Open, JCDO.ClosedExpAcct AS PhaseGL_Closed
       , JCDL.LiabType AS JCDL_LiabType, JCDL.OpenBurdenAcct AS LiabTypeGL_Open, JCDL.ClosedBurdenAcct AS LiabTypeGL_Closed
       , JCDE.EarnType AS JCDE_EarnType, JCDE.OpenLaborAcct AS EarnTypeGL_Open, JCDE.ClosedLaborAcct AS EarnTypeGL_Closed
     FROM JCCD
     LEFT JOIN JCJP ON JCCD.JCCo = JCJP.JCCo AND JCCD.Job = JCJP.Job
     LEFT JOIN JCCM ON JCJP.JCCo = JCCM.JCCo AND JCJP.Contract = JCCM.Contract
     LEFT JOIN JCDM ON JCCM.JCCo = JCDM.JCCo AND JCCM.Department = JCDM.Department
     LEFT JOIN JCDC ON JCDM.JCCo = JCDC.JCCo AND JCDM.Department = JCDC.Department AND JCCD.CostType = JCDC.CostType
     LEFT JOIN JCDE ON JCDM.JCCo = JCDE.JCCo AND JCDM.Department = JCDE.Department AND JCCD.EarnType = JCDE.EarnType
     LEFT JOIN JCDO ON JCDM.JCCo = JCDO.JCCo AND JCDM.Department = JCDO.Department AND JCCD.Phase = JCDO.Phase
     LEFT JOIN JCDL ON JCDM.JCCo = JCDL.JCCo AND JCDM.Department = JCDL.Department AND JCCD.LiabilityType = JCDL.LiabType
     LEFT JOIN xcft_XAWP_FiscalPeriodCutoffs_ForWIPMonth() AS cutoffs ON JCCD.JCCo = cutoffs.GLCo
     WHERE
          JCCD.Mth <= cutoffs.FiscalYear_LastMonth
         AND JCCD.Job IN(SELECT JobNum FROM budxcWIPData_SQL WHERE WIPMonth = @WIPMonthCurrent)
         AND JCCD.JCCo IN(SELECT JCCo FROM JCCO WHERE udExcludeFromWIP <> 'Y' or udExcludeFromWIP IS NULL)
         --AND LTRIM(RTRIM(JCCD.Job)) = '71-'
     GROUP BY
         JCCD.JCCo, JCCD.Job, JCCD.Source, JCCD.Phase, JCCD.EarnType, JCCD.LiabilityType, JCCD.CostType
       , JCDM.Department, JCDM.Description
       , JCDC.CostType, JCDC.OpenWIPAcct, JCDC.ClosedExpAcct
       , JCDO.ExcludePR, JCDO.Phase, JCDO.OpenWIPAcct, JCDO.ClosedExpAcct
       , JCDL.LiabType, JCDL.OpenBurdenAcct, JCDL.ClosedBurdenAcct
       , JCDE.EarnType, JCDE.OpenLaborAcct, JCDE.ClosedLaborAcct
     UPDATE @JCGLDetail
      SET
          ControllingSetting =
        CASE WHEN Phase = JCDO_Phase AND JCDO_ExcludePR = 'N' THEN 'PhaseOverride-PR Excluded'
          WHEN Phase = JCDO_Phase AND JCDO_ExcludePR = 'Y'
           AND EarnType NOT IN(Select EarnType FROM JCDE WHERE JCDE.JCCo = JCCo AND JCDE.Department = DeptNum)
           AND LiabilityType NOT IN(Select LiabType FROM JCDL WHERE JCDL.JCCo = JCCo AND JCDL.Department = DeptNum)
           THEN 'PhaseOverride-PR Not Excluded'
          WHEN EarnType = JCDE_EarnType THEN 'Earn Type Override'
          WHEN LiabilityType = JCDL_LiabType THEN 'Liability Type Override'
          ELSE 'Cost Type' END
     UPDATE @JCGLDetail
      SET
          GLAccountCharged =
        CASE WHEN ControllingSetting = 'PhaseOverride-PR Excluded' OR ControllingSetting = 'PhaseOverride-PR Not Excluded'
          THEN PhaseGL_Open
          WHEN ControllingSetting = 'Earn Type Override' THEN EarnTypeGL_Open
          WHEN ControllingSetting = 'Liability Type Override' THEN LiabTypeGL_Open
          ELSE CostTypeGL_Open END
    RETURN 
    END
    Bob Sutor

    well, did you either restart the instance or add another tempdb file (no restart required) to let other transactions  continue on the server.
    or check if autogrowth was limited, change that to unlimnited , to the transactions conintue..
    the function may be dumping the data on to tempdb, how much data are you excepting back...what are indexes on the tables
    Hope it Helps!!

  • Oracle 11g - Merge PL/SQL issue - Same code work in Oracle10g

    Below PL/SQL block stop working after Oracle11g upgrade, working fine in Oracle10g
    CREATE TABLE TMP_TABLE1 (P_PROVIDER NUMBER, P_ID NUMBER);
    CREATE TABLE TMP_TABLE2 (COL1 NUMBER, COL2 NUMBER);
    CREATE TABLE TMP_TABLE3 (COL3 NUMBER, COL4 NUMBER);
    BEGIN
    FOR i IN (SELECT p_provider p_provider, p_id p_id FROM tmp_table1)
    LOOP
    MERGE INTO TMP_TABLE2 T
    USING ( SELECT I.P_PROVIDER P_PROVIDER,
    I.P_ID P_ID FROM DUAL) DDD
    ON (T.COL1= DDD.P_PROVIDER AND T.COL2 = DDD.P_ID)
    WHEN NOT MATCHED THEN
    INSERT (COL1, COL2) VALUES (1, (SELECT x.COL4 FROM TMP_TABLE3 x WHERE x.COL4 = DDD.P_ID));
    END LOOP;
    END;
    Oracle 10g Version:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE 10.2.0.4.0 Production
    TNS for Solaris: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    Oracle 11g Version:
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    CORE 11.2.0.2.0 Production
    TNS for Linux: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 – Production
    Oracle11 g Error:
    Error at line 5
    ORA-06550: line 11, column 93:
    PL/SQL: ORA-00904: "DDD"."P_ID": invalid identifier
    ORA-06550: line 5, column 7:
    PL/SQL: SQL Statement ignored
    Script Terminated on line 5.
    Is there any patch/work around in Oracle 11g?
    Please advice
    Thank you
    Raj

    We had a similar issue when our organization upgraded to 11gR2.
    It looks like it boils down to a change Oracle made in regards to how it works with correlated subqueries within an insert statement.
    Anyway, this thread has a little more information:
    Merge Command in 10g vs 11g
    And it says to look at Metalink note 1109983.1 (which I can't seem to find).
    Anyway, a workaround in thread is suggests (which worked for us) to wrap the insert subquery around a dummy decode clause, and oddly it will work.
    eg:
    INSERT (COL1, COL2) VALUES (1, (decode(1,1,(SELECT x.COL4 FROM TMP_TABLE3 x WHERE x.COL4 = DDD.P_ID)) ) ) ;
    Quite a kludge, but at least it is an immediate fix to the problem, without having to rewrite anything.

  • SQL issue with with/without where cluase have some data issue

    Hi,
    I have an issue with the below sql. when I apply org filter for certain organization it's not returning the result but when I remove the filter that particular organization appears in the result. Can someone help to identify the cause for that. appreciate for your help.
    the filter I tried with AND T116391.ORG_HIER11_NAME                             = 'IT Hosting Services'
    SELECT DISTINCT T116391.ORG_HIER11_NAME
    FROM WC_TLNT_READINESS_D T310261
    /* Dim_WC_TLNT_READINESS_D */
    WC_TLNT_RETENTION_RISK_D T308248
    /* Dim_WC_TLNT_RETENTION_RISK_D */
    WC_TLNT_LOSS_IMPACT_D T308236
    /* Dim_WC_TLNT_LOSS_IMPACT_D */
    WC_TLNT_EMPLOYEE_D T308163
    /* Dim_WC_TLNT_EMPLOYEE_D */
    W_POSITION_DH T116081
    /* Dim_W_POSITION_DH_Position_Hierarchy */
    W_EMPLOYEE_D T115519
    /* Dim_W_EMPLOYEE_D_Supervisor */
    W_JOB_D T95865
    /* Dim_W_JOB_D */
    W_EMPLOYEE_D T68497
    /* Dim_W_EMPLOYEE_D */
    WC_ROWLVL_SECURITY_D T310120
    /* DIM_WC_ROWLVL_SECURITY_D */
    W_DAY_D T66755
    /* Dim_W_DAY_D_Common */
    W_INT_ORG_D T111939
    /* Dim_W_INT_ORG_D_Employee_Org */
    WC_TLNT_F T308187
    /* Fact_WC_TLNT_F */
    WC_TLNT_RSLTS_POTENTIAL_D T308263
    /* Dim_WC_TLNT_RSLTS_POTENTIAL_D */
    W_PAY_GRADE_D T95908
    /* Dim_W_PAY_GRADE_D */
    WC_ORG_LIST_D T304800
    /* Dim_WC_ORG_LIST_D_OrgSecurity */
    W_INT_ORG_DH T116391
    /* Dim_W_INT_ORG_DH_Employee_Org */
    WHERE ( T308187.LOSS_IMPACT_WID = T308236.ROW_WID
    AND T308163.ROW_WID = T308187.TLNT_EMPLOYEE_WID
    AND T116081.ROW_WID = T308187.EMP_POSTN_DH_WID
    AND T115519.ROW_WID = T308187.SUPERVISOR_WID
    AND T95865.ROW_WID = T308187.JOB_WID
    AND T308187.RETENTION_RISK_WID = T308248.ROW_WID
    AND T66755.X_REVIEW_YEAR_WID = T308187.REVIEW_YEAR_WID
    AND T68497.ROW_WID = T308187.EMPLOYEE_WID
    AND T68497.X_PAY_GRADE_WID = T95908.ROW_WID
    AND T68497.X_I_POPULATION_GROUP = T310120.I_POPULATION_GROUP
    AND T308187.RSLTS_POTENTIAL_WID = T308263.ROW_WID
    AND T95908.ROW_WID = T308187.PAY_GRADE_WID
    AND T111939.ROW_WID = T308187.HR_ORG_WID
    AND T111939.ORG_NUM = T304800.ORGANIZATION_ID
    AND T116391.ORG_WID = T308187.HR_ORG_WID
    AND T116391.BASE_ORG_NUM = T304800.ORGANIZATION_ID
    AND T66755.DAY_DT = TO_DATE('2012-07-10 00:00:00' , 'YYYY-MM-DD HH24:MI:SS')
    AND T116391.ORG_HIER11_NAME                             = 'IT Hosting Services'
    AND T308187.READINESS_WID = T310261.ROW_WID
    AND T308263.RESULTS_POTENTIAL = 'Strong Potential'
    AND T310120.ALLOWED = 'Y'
    AND T310120.ROW_Secuirty_GROUP = 'Corporate Full Data Access'
    AND CAST(T66755.X_REVIEW_YEAR_WID AS CHARACTER ( 30 ) ) = '2012'
    AND CAST(T308187.REVIEW_YEAR_WID AS CHARACTER ( 30 ) ) = '2012'
    AND (T111939.HR_ORG_FLG IN ('U', 'Y'))
    AND (T116391.ROW_WID IN (0)
    OR T116391.W_HIERARCHY_CLASS IN ('HR-ORG'))
    AND (T116391.ROW_WID IN (0)
    OR T116391.HR_ORG_FLG IN ('Y'))
    AND (T116391.ROW_WID IN (0)
    OR T304800.SECURITY_PROFILE_ID IN (-1))
    AND (T111939.HR_ORG_FLG IN ('Y')
    OR T304800.SECURITY_PROFILE_ID IN (-1))
    AND (T116391.ROW_WID IN (0)
    OR T116391.CURRENT_VER_HIER_FLG IN ('Y'))
    AND (T116081.CURRENT_LVL1ANC_LOGIN IN ('N0004404')
    OR T116081.CURRENT_LVL2ANC_LOGIN IN ('N0004404')
    OR T116081.CURRENT_LVL3ANC_LOGIN IN ('N0004404')
    OR T116081.CURRENT_LVL4ANC_LOGIN IN ('N0004404')
    OR T116081.CURRENT_LVL5ANC_LOGIN IN ('N0004404')
    OR T116081.CURRENT_LVL6ANC_LOGIN IN ('N0004404')
    OR T116081.CURRENT_LVL7ANC_LOGIN IN ('N0004404')
    OR T116081.CURRENT_LVL8ANC_LOGIN IN ('N0004404')
    OR T116081.CURRENT_TOP_LVL_LOGIN IN ('N0004404')
    OR T116081.CURRENT_LVL15ANC_LOGIN IN ('N0004404')
    OR T116081.CURRENT_LVL14ANC_LOGIN IN ('N0004404')
    OR T116081.CURRENT_LVL9ANC_LOGIN IN ('N0004404')
    OR T116081.CURRENT_LVL16ANC_LOGIN IN ('N0004404')
    OR T116081.CURRENT_LVL11ANC_LOGIN IN ('N0004404')
    OR T116081.CURRENT_LVL10ANC_LOGIN IN ('N0004404')
    OR T116081.CURRENT_LVL13ANC_LOGIN IN ('N0004404')
    OR T116081.CURRENT_LVL12ANC_LOGIN IN ('N0004404')) )
    order by T116391.ORG_HIER11_NAME desc
    Thanks
    Jay
    Edited by: Jay on Jul 10, 2012 7:51 AM

    How to ask question
    SQL and PL/SQL FAQ
    Handle:     Jay
    Status Level:     Journeyer (280)
    Registered:     Aug 6, 2010
    Total Posts:     350
    Total Questions:     61 (45 unresolved)
    REALLY?

  • OSM DataInstance JDBC Adapter: Invalid SQL issue....

    Hi,
    We are facing one issue while using the database adapter as DataInstance Behavior.
    Here are the scripts we used for the highlighted parameters:
    oms:datasource as XPATH: 'mslv/oms/oms1/internal/jdbc/DataSource'
    oms:sql as XQUERY:
    <instance name="OSM" xsi:type="externalInstanceType">
    <adapter>com.mslv.oms.view.rule.adapter.DatabaseAdapter</adapter>
    <parameter  name="oms:dataSource"> 'mslv/oms/oms1/internal/jdbc/DataSource'</parameter>
    <parameter name="oms:sql">
    "SELECT P.NODE_VALUE_TEXT FROM ORDERMGMT_OSMINSTALL.OM_ORDER_INSTANCE  P
    JOIN ORDERMGMT_OSMINSTALL.OM_ORDER_DATA_DICTIONARY PP
    ON P.DATA_DICTIONARY_ID=PP.DATA_DICTIONARY_ID
    where  PP.DATA_DICTIONARY_MNEMONIC='site_id' "
    </parameter>
    </instance>
    The following error logged in Logfile:
    <Feb 18, 2014 5:30:16 AM IST> <Error> <oms> <BEA-000000> <impl.j: failed to invoke adapter for externalInstanceType: name[DataInstance] class[com.mslv.oms.view.rule.adapter.DatabaseAdapter]
    com.mslv.oms.view.rule.adapter.AdapterException: java.sql.SQLSyntaxErrorException: ORA-00900: invalid SQL statement
            at com.mslv.oms.view.rule.adapter.DatabaseAdapter.retrieveInstance(Unknown Source)
            at oracle.communications.ordermanagement.rule.impl.j.getExternalInstance(Unknown Source)
            at oracle.communications.ordermanagement.rule.impl.j.findInstance(Unknown Source)
            at oracle.communications.ordermanagement.rule.impl.a.a(Unknown Source)
            at oracle.communications.ordermanagement.rule.impl.a.a(Unknown Source)
            Truncated. see log file for complete stacktrace
    Caused By: java.sql.SQLSyntaxErrorException: ORA-00900: invalid SQL statement
            at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:91)
            at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133)
            at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:206)
            at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
            at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:413)
            Truncated. see log file for complete stacktrace
    Can you pls suggest the remedy for this issue in the SQL? The same SQL runs well in TOAD and also shows the selected rows.
    Thanks in advance..

    Thanks Viktor.
    I have not tried the Webservice option due to the processing time to retrieve all the orders and then this particular field.
    But I have tried both lookup as well as calculate behaviors.
    Now I am neither getting any exception in the log nor the update reflects in my Webclient task view. Have your view gets updated with the calculate behavior?
    I am using OSM SDK version [7.0.3.745].
    My task_view.xml shows as following with lookup:
    <viewNode element="b_end_site_id">
        <editable>true</editable>  <minOccurs>1</minOccurs>
        <maxOccurs>1</maxOccurs>
            <viewRule xsi:type="dataInstanceRuleType">
                <description>DataInstance</description>
                <instance xsi:type="externalInstanceType"
                    name="DataInstance">
                    <adapter>com.mslv.oms.view.rule.adapter.DatabaseAdapter</adapter>
                    <parameter name="oms:dataSource">&#039;mslv/oms/oms1/internal/jdbc/DataSource&#039;</parameter>
                    <parameter name="oms:sql">&#039;SELECT P.NODE_VALUE_TEXT FROM ORDERMGMT_OSMINSTALL.OM_ORDER_INSTANCE  P
    JOIN ORDERMGMT_OSMINSTALL.OM_ORDER_DATA_DICTIONARY PP
    ON P.DATA_DICTIONARY_ID=PP.DATA_DICTIONARY_ID
    where  PP.DATA_DICTIONARY_MNEMONIC=?&#039;
    </parameter>
                    <parameter name="in:1">&#039;site_id&#039;</parameter>
                    <cache>
                        <scope>SYSTEM</scope>
                        <timeout>15000</timeout>
                        <maxSize>50</maxSize>
                    </cache>
                </instance>
            </viewRule>
            <viewRule xsi:type="lookupRuleType">
                <annotation>
                    <documentation>This behavior retrieves the inline XML defined for the data instance behavior and displays it  as a lookup field, which is the same as a dropdown list field,  in the Web client</documentation>
                </annotation>
                <description>LookUp</description>
                <itemset>
                    <nodeset>instance(&#039;DataInstance&#039;)/rowSet/row/NODE_VALUE_TEXT</nodeset>
                    <value name="Value" openSelectionSeverity="CRITICAL" sortOrder="0" sortDirection="ascending" hidden="false" position="0">
                        <node>text()</node>
                    </value>
                </itemset>
            </viewRule>
    </viewNode>
    With Calculate, it shows following:
    <viewNode element="a_end_site_id">
        <editable>true</editable>  <minOccurs>1</minOccurs>
        <maxOccurs>1</maxOccurs>
            <viewRule xsi:type="dataInstanceRuleType">
                <description>DataInstance</description>
                <instance xsi:type="externalInstanceType"
                    name="DataInstance">
                    <adapter>com.mslv.oms.view.rule.adapter.DatabaseAdapter</adapter>
                    <parameter name="oms:dataSource">&#039;mslv/oms/oms1/internal/jdbc/DataSource&#039;</parameter>
                    <parameter name="oms:sql">&#039;SELECT P.NODE_VALUE_TEXT FROM ORDERMGMT_OSMINSTALL.OM_ORDER_INSTANCE  P
    JOIN ORDERMGMT_OSMINSTALL.OM_ORDER_DATA_DICTIONARY PP
    ON P.DATA_DICTIONARY_ID=PP.DATA_DICTIONARY_ID
    where  PP.DATA_DICTIONARY_MNEMONIC=?&#039; </parameter>
                    <parameter name="in:1">&#039;site_id&#039;</parameter>
                    <cache>
                        <scope>SYSTEM</scope>
                        <timeout>15000</timeout>
                        <maxSize>50</maxSize>
                    </cache>
                </instance>
            </viewRule>
            <viewRule xsi:type="calculateRuleType">
                <description>Calculation</description>
                <calculation>instance(&#039;DataInstance&#039;)/rowSet/row/NODE_VALUE_TEXT/text()</calculation>
            </viewRule>
    </viewNode>

  • WCF-SQL issue

    Hi All,
    I have two Biztalk applications A & B, where I am using wcf-sql in both of them.
    In A it's working fine , But in B it's giving the following error when I start recieve location.
    WCF-SQL
    System.InvalidOperationException: TransactedBatchingBehavior validation failed. The service endpoint cannot be started. TransactedBatchingBehavior requires a binding that contains a binding element ITransactedBindingElement that returns true for ITransactedBindingElement.TransactedReceiveEnabled.
    If you are using NetMsmqBinding or MsmqIntegrationBinding make sure that ExactlyOnce is set to true. at System.ServiceModel.Description.TransactedBatchingBehavior.System.ServiceModel.Description.IEndpointBehavior.Validate(ServiceEndpoint serviceEndpoint) at
    System.ServiceModel.Description.ServiceEndpoint.Validate(Boolean runOperationValidators, Boolean isForService) at System.ServiceModel.Description.DispatcherBuilder.ValidateDescription(ServiceDescription description, ServiceHostBase serviceHost) at System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription
    description, ServiceHostBase serviceHost) at System.ServiceModel.ServiceHostBase.InitializeRuntime() at Microsoft.BizTalk.Adapter.Wcf.Runtime.BtsServiceHostBase.InitializeRuntime() at System.ServiceModel.ServiceHostBase.OnBeginOpen() at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan
    timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfReceiveEndpoint.Enable() at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfReceiveEndpoint..ctor(BizTalkEndpointContext endpointContext,
    IBTTransportProxy transportProxy, ControlledTermination control) at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfReceiver`2.AddReceiveEndpoint(String url, IPropertyBag adapterConfig, IPropertyBag bizTalkConfig)
    Please let me know your suggestions,
    Thanks in Advance.

    Hi,
    Similiar issue is discussed here
    http://social.msdn.microsoft.com/Forums/en-US/6da21689-4aaa-426f-a1c9-ae08e0e1f698/message-order-and-wcfcustom-transport-properties-dialog-box?forum=biztalkr2adapters
    Thanks,
    Deepthi

  • SQL Issue Access Violation at address 09513DC9

    Access violation at address 09513DC9 in module 'WDBHandler.dll'. Write of address 00000000

    I use Taxware to make the backup
    I don't no how to run @@ on 2005 I use SQL Server management studio
    Same as you do for other SQL server versions. Just go to SSMS open new query and type below
    select @@version
    Can you give more error information did you got any stack dump. Can you please check SQL server errorlog . I guess this could be issue with tool you are using but not sure
    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it
    My Technet Articles

  • Really bizzare SQL issued by BI server 11.1.3

    From OBIEE answers I select one column from a single fact table using a time and location dimension. The SQL that gets issued by the BI SERVER to the backend database contains an outer join over a COMPLETELY UNRELATED Fact table, which produces incorrect results in the resulting data displayed under Answers (Analytics). All of the fact tables are modeled as separate Logical Tables with separate sources at the physical layer.
    Has anyone else experienced this problem? What did you do to solve it?
    Thanks.

    Not sure if its an OBIEE 11g issue but if you define oute joins in BMM layer thats have multiple LTS.Sometimes OBIEE will behacve in such a way.
    Regards,
    Sandeep

  • Issue: No Data loaded from Query - MDX, SQL issue

    Hello,
    I'm having a problem with a report based on Query with a hierarchy (0GLACCEXT Hierarchie, Data in Cube 0FIGL_V10), first version of query had 3 filters, but I also tried to load the data without filters thinking it coused the problem - didn't help to fix the issue.
    If I put some characteristics into the report  - the fields are empty - i did "browse data" in the database and found out that only the data for the "year" was fetched by the SQL expression even though I have some similar reports with hierarchies based on 0GL_Account and data is fetched correctly in those ones.
    I tried MDXTEST on SQL expression
    "SELECT {[Measures].[D5LABJ7EYP982LUFOJAXZ3Z3E]} ON COLUMNS,  NON EMPTY [0GLACCEXT                     CVIS].MEMBERS DIMENSION PROPERTIES [0GLACCEXT                     CVIS].[40GLACCEXT] ON ROWS FROM [0FIGL_V10/ZEN_FIGL_V10_Q0001]"
    Data is being loaded.
    What else can I try?
    ps: just found out that data is not fetched when i assign a hierarchie no matter which one (could it be the issue due to the size of hierarchy?)
    Edited by: Elizaveta Nikitina on May 5, 2009 3:33 PM

    Please re-post if this is still an issue to the Data Connectivity - Crystal Reports Forum or purchase a case and have a dedicated support engineer work with you directly

Maybe you are looking for

  • Cannot Install Adobe Updates / Cannot Open Files in Photoshop from LR

    Hi, I cannot seem to update the programs that show need to be updated. My computer shows I need to update Adboe Bridge CS5, Extension Manager, Photoshop CS5 and Camera Raw, but get the following error every time: "There was an  error downloading this

  • 2 ipods using the same itunes library

    Hi I have just given my hubbie an Ipod Nano for xmas and he already has an old one which he is now going to use just for when he is running. He wants to use some of the music on his current library on his old Nano and also use all of the music he has

  • DMS Document Attachment for Z Transactions

    Dear All, I have a Z transaction ( Module Pool ) , its getting used for some customer business process which is not mapped in sap. now my user requirement is that he wants to attach some documents ( diff types ) to that ztransaction like DMS function

  • How to activate business content for 0TCA_DS01

    I need to set up authorizations in netweaver BI using the following objects: 0tca_ds01 0tca_ds02 0tca_ds03 0tca_ds04 0tca_ds05 I've looked at trxn RSA5 in our HR system, but I'm not able to identify the datasources that feed the 0tca_ds0* objects.  W

  • Change system name? 11.5.10.2+

    Hi, Is it possible to change the system name of an instance? What does it affect? Do we do it just by changing the name in the context file and running autoconfig? I am asking this question because, after a clone we dont usually change the system nam