Loop through reference cursor insert into API and catch exceptions - plsql

I am not sure why I am encountering an exception error. I am still learning PL/SQL. I am trying to put some data into a cursor from a table. Then loop through the cursor and insert the data into an API and catch the records that are rejected by the API's. Can I do one loop for multiple API's? Is there something else that I am missing?
declare
fhw UTL_FILE.FILE_TYPE;
wdir varchar2(100);
wfilename varchar2(100);
cnt number;
aidy number;
--
TYPE NextGen_rec IS RECORD(
r_pidm rprawrd.rprawrd_pidm%TYPE,
r_aidy_code rprawrd.rprawrd_aidy_code%TYPE,
r_term_code rpratrm.rpratrm_term_code%TYPE,
r_fund_code rprawrd.rprawrd_fund_code%TYPE,
r_awst_code rprawrd.rprawrd_awst_code%TYPE,
r_awst_date rprawrd.rprawrd_awst_date%TYPE,
r_accept_amt rprawrd.rprawrd_accept_amt%TYPE,
r_accept_date rprawrd.rprawrd_accept_date%TYPE,
r_offer_amt rprawrd.rprawrd_offer_amt%TYPE,
r_offer_date rprawrd.rprawrd_offer_date%TYPE,
r_data_origin rprawrd.rprawrd_data_origin%TYPE
);
--
--
TYPE cur1 IS REF CURSOR;
ng cur1;
--
Begin
--
Wdir := 'UTL_TTU_ST';
wfilename := 'ng_errors.csv';
fhw := UTL_FILE.FOPEN(wdir,wfilename,'w');
select count (*) into cnt
from ttubanr.NGAWARDLD, ttubantemp.NGAWARD
where NGAWARD_AIDY = NGAWARDLD_AIDY;
--
if cnt = 0 then
select NGAWARD_AIDY into aidy from ttubantemp.NGAWARD
where ROWNUM < 2;
--insert aid year if it doesn't exist with date from 01-01-2000 as place holder.
insert into ttubanr.NGAWARDLD
(NGAWARDLD_AIDY, NGAWARDLD_LD)
SELECT replace(replace (REPLACE (NGAWARD_AIDY, 'Academic Year ',null),'20',null),'-',null), '01-JAN-2017' FROM ttubantemp.NGAWARD;
end if;
-- Last date for aid year found
--
for award_rec in ng_rec loop
If cnt = 1 then
open ng FOR
SELECT NGAWARD_NGID,
replace(replace (REPLACE (NGAWARD_AIDY, 'Academic Year ',null),'20',null),'-',null)NGAWARD_AIDY,
CASE
WHEN NGAWARD_PERIOD = 'FALL'
THEN SUBSTR(NGAWARD_AIDY,15,4)||80
WHEN NGAWARD_PERIOD = 'SPRING'
THEN SUBSTR(NGAWARD_AIDY,20,4)||10
END NGAWARD_TERM,
(SELECT SPRIDEN_PIDM FROM SPRIDEN WHERE SPRIDEN_ID = NGAWARD_ID AND SPRIDEN_CHANGE_IND IS NULL) NGAWARD_PIDM,
NGAWARD_ID,
NGAWARD_FUND,
NGAWARD_AMT,
CASE WHEN NGAWARD_PERIOD = 'ANNUAL'
THEN 'A'
WHEN NGAWARD_PERIOD = 'FALL'
THEN 'F'
WHEN NGAWARD_PERIOD = 'SPRING'
THEN 'S'
END NGAWARD_PERIOD,
CASE WHEN NGAWARD_STATUS = 'GrantAward'
THEN 'I'
WHEN NGAWARD_STATUS = 'ModifyAward'
THEN 'U'
WHEN NGAWARD_STATUS = 'RemoveSingleSeasonAward'
THEN 'C'
WHEN NGAWARD_STATUS = 'RevokeRenewableAward'
THEN 'C'
WHEN NGAWARD_STATUS = 'DeleteAward'
THEN 'C'
END NGAWARD_STATUS,
NGAWARD_ADATE
FROM ttubantemp.NGAWARD, ttubanr.NGAWARDLD, SPRIDEN
WHERE
SPRIDEN_ID = NGAWARD_ID
AND NGAWARD_AIDY = NGAWARDLD_AIDY
and NGAWARD_ADATE > NGAWARDLD_LDATE
AND SPRIDEN_CHANGE_IND IS NULL
order by NGAWARD_ID, NGAWARD_FUND, NGAWARD_ADATE;
fetch ng into ng_rec;
End If;
--
IF ng_rec.NGAWARD_PERIOD = 'A' AND ng_rec.NGAWARD_STATUS = 'I'
THEN
rp_award.p_create(p_aidy_code => ng_rec.NGAWARD_AIDY,
p_pidm => ng_rec.NGAWARD_PIDM,
p_fund_code => ng_rec.NGAWARD_FUND,
p_awst_code => 'A',
p_awst_date => sysdate,
p_accept_amt => ng_rec.NGAWARD_AMT,
p_accept_date => sysdate,
p_offer_amt => ng_rec.NGAWARD_AMT,
p_offer_date => sysdate,
p_data_origin => 'NextGen');
--
gb_common.p_commit;
--Year award Update
ELSIF ng_rec.NGAWARD_PERIOD = 'A' AND ng_rec.NGAWARD_STATUS = 'U'
THEN
rp_award.p_update(p_aidy_code => ng_rec.NGAWARD_AIDY,
p_pidm => ng_rec.NGAWARD_PIDM,
p_fund_code => ng_rec.NGAWARD_FUND,
p_awst_code => 'A',
p_awst_date => sysdate,
p_accept_amt => ng_rec.NGAWARD_AMT,
p_accept_date => sysdate,
p_offer_amt => ng_rec.NGAWARD_AMT,
p_data_origin => 'NextGen');
--
gb_common.p_commit;
--Year award cancel
ELSIF ng_rec.NGAWARD_PERIOD = 'A' AND ng_rec.NGAWARD_STATUS = 'C'
THEN
rp_award.p_update(p_aidy_code => ng_rec.NGAWARD_AIDY,
p_pidm => ng_rec.NGAWARD_PIDM,
p_fund_code => ng_rec.NGAWARD_FUND,
p_awst_code => 'C',
p_awst_date => sysdate,
p_data_origin => 'NextGen');
--
gb_common.p_commit;
--Term award insert
ELSIF ng_rec.NGAWARD_PERIOD in ('F','S') AND ng_rec.NGAWARD_STATUS = 'I'
THEN
rp_award_schedule.p_create(p_aidy_code => ng_rec.NGAWARD_AIDY,
p_term_code => ng_rec.NGAWARD_TERM,
p_pidm => ng_rec.NGAWARD_PIDM,
p_fund_code => ng_rec.NGAWARD_FUND,
p_awst_code => 'A',
p_awst_date => sysdate,
p_accept_amt => ng_rec.NGAWARD_AMT,
p_accept_date => sysdate,
p_offer_amt => ng_rec.NGAWARD_AMT,
p_offer_date => sysdate,
p_data_origin => 'NextGen');
--
gb_common.p_commit;
--Term award update
ELSIF ng_rec.NGAWARD_PERIOD in ('F','S') AND ng_rec.NGAWARD_STATUS = 'U'
THEN
rp_award_schedule.p_update(p_aidy_code => ng_rec.NGAWARD_AIDY,
p_term_code => ng_rec.NGAWARD_TERM,
p_pidm => ng_rec.NGAWARD_PIDM,
p_fund_code => ng_rec.NGAWARD_FUND,
p_accept_amt => ng_rec.NGAWARD_AMT,
p_offer_amt => ng_rec.NGAWARD_AMT,
p_data_origin => 'NextGen');
--
gb_common.p_commit;
EXCEPTION
WHEN OTHERS THEN
gb_common.p_rollback;
IF SQLCODE = gb_event.APP_ERROR THEN
utl_file.put_line(fhw,'Rollback renumbering '||sqlerrm||','||ng_rec.NGAWARD_NGID||','||ng_rec.NGAWARD_ID||','||ng_rec.NGAWARD_AIDY||','||ng_rec.NGAWARD_TERM||','||ng_rec.NGAWARD_FUND||','||ng_rec.NGAWARD_AMT||','||ng_rec.NGAWARD_STATUS||','||ng_rec.NGAWARD_ADATE);
--
end loop;
--
end if;
--
--CLOSE ng_rec;
UTL_FILE.FCLOSE(fhw);
end;

Related

Extract values from nested object in plsql using Apex

I have this employee object and I need to store every value into variables.
I am wondering if it is an easy or smart way to get the values from nested objects.
I know I can get the values in this way:
v_first_name := APEX_JSON.get_varchar2(p_path => 'employee.firstName')
but how can I retrieve the values from address object or from options object?
Apex version 20.1.
{
"employee":{
"firstName":"John",
"lastName":"Smith",
"email":"jsmith#test.com",
"phoneNumber":"‎(907) 247-8888",
"address":{
"street":"1527 Pond Reef Rd",
"city":"Ketchikan",
"state":"ALaska",
"stateShort":"AK",
"zipCode":99901,
"country":"USA"
},
"categories":[
{
"categoryID":1,
"categoryName":"Example1",
"options":{
"ind_1":1,
"ind_2":0,
"ind_3":0
}
},
{
"categoryID":2,
"categoryName":"Example",
"options":{
"ind_1":1,
"ind_2":1,
"ind_3":1
}
}
]
}
}
address is just a nested json object so you can use the "dot" notation. categories is an array so you need to loop through the individual elements. Here is an example.
SET SERVEROUTPUT ON
DECLARE
l_json_text VARCHAR2(32767);
l_count PLS_INTEGER;
l_members WWV_FLOW_T_VARCHAR2;
l_paths APEX_T_VARCHAR2;
l_exists BOOLEAN;
l_json_values apex_json.t_values;
BEGIN
l_json_text := '
{
"employee":{
"firstName":"John",
"lastName":"Smith",
"email":"jsmith#test.com",
"phoneNumber":"‎(907) 247-8888",
"address":{
"street":"1527 Pond Reef Rd",
"city":"Ketchikan",
"state":"ALaska",
"stateShort":"AK",
"zipCode":99901,
"country":"USA"
},
"categories":[
{
"categoryID":1,
"categoryName":"Example1",
"options":{
"ind_1":1,
"ind_2":0,
"ind_3":0
}
},
{
"categoryID":2,
"categoryName":"Example",
"options":{
"ind_1":1,
"ind_2":1,
"ind_3":1
}
}
]
}
}
';
apex_json.parse(
p_values => l_json_values,
p_source => l_json_text
);
DBMS_OUTPUT.put_line('----------------------------------------');
if apex_json.does_exist(p_path => 'employee.address.street',p_values => l_json_values) then
dbms_output.put_line('address: '||apex_json.get_varchar2(p_path => 'employee.address.street', p_values => l_json_values));
end if;
DBMS_OUTPUT.put_line('----------------------------------------');
DBMS_OUTPUT.put_line('----------------------------------------');
if apex_json.does_exist(p_path => 'employee.categories',p_values => l_json_values) then
dbms_output.put_line(APEX_JSON.get_count(p_path => 'employee.categories', p_values => l_json_values) || ' Categories found');
FOR r IN 1 .. APEX_JSON.get_count(p_path => 'employee.categories', p_values => l_json_values) LOOP
DBMS_OUTPUT.put_line('categoryName: '||apex_json.get_varchar2(p_path => 'employee.categories[%d].categoryName', p0 => r, p_values => l_json_values));
DBMS_OUTPUT.put_line('options.ind_1: '||apex_json.get_varchar2(p_path => 'employee.categories[%d].options.ind_1', p0 => r, p_values => l_json_values));
END LOOP;
end if;
DBMS_OUTPUT.put_line('----------------------------------------');
END;
/
----------------------------------------
address: 1527 Pond Reef Rd
----------------------------------------
----------------------------------------
2 Categories found
categoryName: Example1
options.ind_1: 1
categoryName: Example
options.ind_1: 1
----------------------------------------
PL/SQL procedure successfully completed.

PLSQL : Return Concatenated string of all attributes of a Object

--Declare Object
create or replace TYPE INP_OBJ AS OBJECT
( attribute_1 VARCHAR2(20 CHAR)
,attribute_2 VARCHAR2(20 CHAR)
);
--Create Package
CREATE OR REPLACE PACKAGE TEST AS
PROCEDURE PROC1 (l_inp_obj IN INP_OBJ) ;
END TEST;
--Create Package Body
create or replace PACKAGE BODY TEST AS
PROCEDURE PROC1 (l_inp_obj IN INP_OBJ) IS
BEGIN
dbms_output.put_line(l_inp_obj.attribute_1 || ' ~ '|| l_inp_obj.attribute_2);
-- have to write every element individually here
END PROC1;
END TEST;
-- Calling Procedure
DECLARE
L_INP_OBJ INP_OBJ;
BEGIN
L_INP_OBJ := (INP_OBJ('VALUE OF ATTR 1'
,'VALUE OF ATTR 2'));
TEST.PROC1(L_INP_OBJ => L_INP_OBJ);
END;
for display I had to write every attribute of input object individually. Is there a better way to return concatenated string of all values of Input Object ?
From my answer to this similar question, you can write a package:
CREATE PACKAGE reflection IS
TYPE type_info IS RECORD(
prec PLS_INTEGER,
scale PLS_INTEGER,
len PLS_INTEGER,
csid PLS_INTEGER,
csfrm PLS_INTEGER,
schema_name VARCHAR2(30),
type_name VARCHAR2(30),
version VARCHAR2(100),
count PLS_INTEGER
);
TYPE attr_info IS RECORD(
prec PLS_INTEGER,
scale PLS_INTEGER,
len PLS_INTEGER,
csid PLS_INTEGER,
csfrm PLS_INTEGER,
attr_elt_type ANYTYPE,
aname VARCHAR2(30)
);
FUNCTION get_size(
p_anydata IN ANYDATA
) RETURN PLS_INTEGER;
FUNCTION get_attr_name_at(
p_anydata IN ANYDATA,
p_index IN PLS_INTEGER DEFAULT 1
) RETURN VARCHAR2;
FUNCTION get_attr_value_at(
p_anydata IN ANYDATA,
p_index IN PLS_INTEGER DEFAULT 1
) RETURN VARCHAR2;
END;
/
With the body:
CREATE PACKAGE BODY reflection IS
DEBUG BOOLEAN := FALSE;
FUNCTION get_type(
p_anydata IN ANYDATA
) RETURN ANYTYPE
IS
v_typeid PLS_INTEGER;
v_anytype ANYTYPE;
v_type_info REFLECTION.TYPE_INFO;
BEGIN
v_typeid := p_anydata.GetType( typ => v_anytype );
RETURN v_anytype;
END;
FUNCTION get_info(
p_anytype IN ANYTYPE
) RETURN type_info
IS
v_typeid PLS_INTEGER;
v_type_info REFLECTION.TYPE_INFO;
BEGIN
v_typeid := p_anytype.GetInfo (
v_type_info.prec,
v_type_info.scale,
v_type_info.len,
v_type_info.csid,
v_type_info.csfrm,
v_type_info.schema_name,
v_type_info.type_name,
v_type_info.version,
v_type_info.count
);
IF v_typeid <> DBMS_TYPES.TYPECODE_OBJECT THEN
RAISE_APPLICATION_ERROR( -20000, 'Not an object.' );
END IF;
RETURN v_type_info;
END;
FUNCTION get_size(
p_anydata IN ANYDATA
) RETURN PLS_INTEGER
IS
BEGIN
RETURN Get_Info( Get_Type( p_anydata ) ).COUNT;
END;
FUNCTION get_attr_name_at(
p_anydata IN ANYDATA,
p_index IN PLS_INTEGER DEFAULT 1
) RETURN VARCHAR2
IS
v_anydata ANYDATA := p_anydata;
v_anytype ANYTYPE;
v_type_info REFLECTION.TYPE_INFO;
v_output VARCHAR2(4000);
v_attr_typeid PLS_INTEGER;
v_attr_info REFLECTION.ATTR_INFO;
BEGIN
v_anytype := Get_Type( v_anydata );
v_type_info := Get_Info( v_anytype );
IF p_index < 1 OR p_index > v_type_info.COUNT THEN
RETURN NULL;
END IF;
v_anydata.PIECEWISE;
v_attr_typeid := v_anytype.getAttrElemInfo(
pos => p_index,
prec => v_attr_info.prec,
scale => v_attr_info.scale,
len => v_attr_info.len,
csid => v_attr_info.csid,
csfrm => v_attr_info.csfrm,
attr_elt_type => v_attr_info.attr_elt_type,
aname => v_attr_info.aname
);
RETURN v_attr_info.aname;
END;
FUNCTION get_attr_value_at(
p_anydata IN ANYDATA,
p_index IN PLS_INTEGER DEFAULT 1
) RETURN VARCHAR2
IS
v_anydata ANYDATA := p_anydata;
v_anytype ANYTYPE;
v_type_info REFLECTION.TYPE_INFO;
v_output VARCHAR2(4000);
BEGIN
v_anytype := Get_Type( v_anydata );
v_type_info := Get_Info( v_anytype );
IF p_index < 1 OR p_index > v_type_info.COUNT THEN
RETURN NULL;
END IF;
v_anydata.PIECEWISE;
FOR i IN 1 .. p_index LOOP
DECLARE
v_attr_typeid PLS_INTEGER;
v_attr_info REFLECTION.ATTR_INFO;
v_result_code PLS_INTEGER;
BEGIN
v_attr_typeid := v_anytype.getAttrElemInfo(
pos => i,
prec => v_attr_info.prec,
scale => v_attr_info.scale,
len => v_attr_info.len,
csid => v_attr_info.csid,
csfrm => v_attr_info.csfrm,
attr_elt_type => v_attr_info.attr_elt_type,
aname => v_attr_info.aname
);
IF DEBUG THEN
DBMS_OUTPUT.PUT_LINE(
'Attribute ' || i || ': '
|| v_attr_info.aname
|| ' (type ' || v_attr_typeid || ')'
);
END IF;
CASE v_attr_typeid
WHEN DBMS_TYPES.TYPECODE_NUMBER THEN
DECLARE
v_value NUMBER;
BEGIN
v_result_code := v_anydata.GetNumber( v_value );
IF i = p_index THEN
RETURN TO_CHAR( v_value );
END IF;
END;
WHEN DBMS_TYPES.TYPECODE_VARCHAR2 THEN
DECLARE
v_value VARCHAR2(4000);
BEGIN
v_result_code := v_anydata.GetVarchar2( v_value );
IF i = p_index THEN
RETURN v_value;
END IF;
END;
WHEN DBMS_TYPES.TYPECODE_DATE THEN
DECLARE
v_value DATE;
BEGIN
v_result_code := v_anydata.GetDate( v_value );
IF i = p_index THEN
RETURN TO_CHAR( v_value, 'YYYY-MM-DD HH24:MI:SS' );
END IF;
END;
ELSE
NULL;
END CASE;
END;
END LOOP;
RETURN NULL;
END;
END;
/
Then you can iterate over the object to find the attributes and write the package as:
CREATE PACKAGE TEST AS
PROCEDURE PROC1 (p_anydata IN ANYDATA);
END TEST;
/
CREATE PACKAGE BODY TEST AS
PROCEDURE PROC1 (p_anydata IN ANYDATA)
IS
p_attr_name VARCHAR2(30);
p_attr_value VARCHAR2(4000);
BEGIN
FOR attr_no IN 1 .. REFLECTION.get_size(p_anydata) LOOP
p_attr_name := REFLECTION.get_attr_name_at(p_anydata, attr_no);
p_attr_value := REFLECTION.get_attr_value_at(p_anydata, attr_no);
IF attr_no > 1 THEN
DBMS_OUTPUT.PUT( ' ~ ' );
END IF;
DBMS_OUTPUT.PUT( p_attr_value );
END LOOP;
DBMS_OUTPUT.NEW_LINE;
END PROC1;
END TEST;
/
Then call it using:
DECLARE
L_INP_OBJ INP_OBJ;
BEGIN
L_INP_OBJ := INP_OBJ('VALUE OF ATTR 1' ,'VALUE OF ATTR 2');
TEST.PROC1(P_ANYDATA => ANYDATA.ConvertObject(L_INP_OBJ);
END;
/

Wordpress meta_query

I'm struggling with a wp_query and i need your help.
I have 3 custom fields called "Agenda_day", "Agenda_month", "Agenda_year", representing the day, month and year of an event.
I want to order the results of my query by day, then month, and finally year, ascendingly.
Here is my query :
$query_agenda = new WP_Query(
array(
'posts_per_page' => 8,
'cat' => 4,
'meta_query' =>
array(
'relation' => 'AND',
'day' => array('key' => 'Agenda_day', 'compare' => 'EXISTS'),
'month' => array('key' => 'Agenda_month', 'compare' => 'EXISTS'),
'year' => array('key' => 'Agenda_year', 'compare' => 'EXISTS')
),
'orderby' => array('day' => 'ASC', 'month' => 'ASC', 'year' => 'ASC')
)
);
And this does not work ... can you explain me why and show me how to fix it ?
Thank you !
EDIT
Here is the executed query (results are returned but not well ordered)
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) INNER JOIN wp_postmeta AS mt1 ON ( wp_posts.ID = mt1.post_id ) INNER JOIN wp_postmeta AS mt2 ON ( wp_posts.ID = mt2.post_id ) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (4) ) AND ( wp_postmeta.meta_key = 'Agenda_jour' AND mt1.meta_key = 'Agenda_mois' AND mt2.meta_key = 'Agenda_annee' ) AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') GROUP BY wp_posts.ID ORDER BY CAST(wp_postmeta.meta_value AS CHAR) ASC, CAST(mt1.meta_value AS CHAR) ASC, CAST(mt2.meta_value AS CHAR) ASC LIMIT 0, 8
https://codex.wordpress.org/Class_Reference/WP_Query
https://codex.wordpress.org/Class_Reference/WP_Meta_Query
please check above both links you will get your answer and your orderby arguments which you are passing it's wrong
Problem solved !
i was dealing with different formats in the custom fields : some days and months were on 1 character ("6") and others on two ("06"), so the system couldn't sort it well
second point is, as i'm dealing with dates, i have to reorder the "orderby" instruction from "day, month, year" to "year, month, day"

Copying Responsibility in oracle ebs

user 'a' has 10 responsibilities in oracle EBS and user 'b' has 2 , i want to copy the remaining 8 responsibilities from user 'a' to 'b' using Pl/Sql procedure, how to do that. I tried the following code but it didn't compare the already common responsibility.
DECLARE
--
resp_count NUMBER := 0;
--
CURSOR src_user_resp_details
IS
SELECT DISTINCT fa.application_short_name,
fr.responsibility_key ,
fsg.security_group_key
FROM fnd_application fa ,
fnd_responsibility fr ,
fnd_user fu ,
fnd_user_resp_groups_all furga,
fnd_security_groups fsg
WHERE 1 = 1
AND fu.user_name = 'XX_ORACLE_APPS_DNA_1'
AND fu.user_id = furga.user_id
AND fa.application_id = fr.application_id
AND furga.responsibility_id = fr.responsibility_id
AND furga.responsibility_application_id = fa.application_id
AND fsg.security_group_id = furga.security_group_id
-- AND furga.end_date IS NULL OR trunc(furga.end_date) > trunc(SYSDATE)
AND furga.end_date IS NULL;
--
--
BEGIN
FOR user_resp_details_rec IN src_user_resp_details
LOOP
BEGIN
--
fnd_user_pkg.addresp
(username => 'XX_ORACLE_APPS_DNA_2',
resp_app => user_resp_details_rec.application_short_name,
resp_key => user_resp_details_rec.responsibility_key,
security_group => user_resp_details_rec.security_group_key,
description => NULL,
start_date => SYSDATE,
end_date => NULL
);
--
resp_count := resp_count + 1;
--
EXCEPTION
WHEN OTHERS THEN
--
DBMS_OUTPUT.put_line ( 'Error while Adding Responsibility: ' || SQLERRM );
DBMS_OUTPUT.put_line ( 'resp_app: ' || user_resp_details_rec.application_short_name );
DBMS_OUTPUT.put_line ( 'resp_key: ' || user_resp_details_rec.responsibility_key );
--
END;
END LOOP;
--
DBMS_OUTPUT.put_line (resp_count || ' Responsibilities Successfully Copied!!' );
--
COMMIT;
END;
The idea here is to exclude the already existin responsiblities in the Cursor only and pass those to the calling Procedure in the begin construct. Hope this helps.
DECLARE
--
resp_count NUMBER := 0;
--
CURSOR src_user_resp_details
IS
SELECT DISTINCT fa.application_short_name,
fr.responsibility_key ,
fsg.security_group_key
FROM fnd_application fa ,
fnd_responsibility fr ,
fnd_user fu ,
fnd_user_resp_groups_all furga,
fnd_security_groups fsg
WHERE 1 = 1
AND fu.user_name = 'XX_ORACLE_APPS_DNA_1'
AND fu.user_id = furga.user_id
AND fa.application_id = fr.application_id
AND furga.responsibility_id = fr.responsibility_id
AND furga.responsibility_application_id = fa.application_id
AND fsg.security_group_id = furga.security_group_id
-- AND furga.end_date IS NULL OR trunc(furga.end_date) > trunc(SYSDATE)
AND FURGA.END_DATE IS NULL
AND furga.responsibility_id NOT IN --Exclude those resposibilites which are already there in User 2. Only those resp whoch are present in 1 but not in 2
(SELECT RESPONSIBILITY_ID
FROM FND_APPLICATION FA2 ,
FND_RESPONSIBILITY FR2 ,
FND_USER FU2 ,
FND_USER_RESP_GROUPS_ALL FURGA2,
fnd_security_groups fsg2
WHERE 1 = 1
AND FU2.USER_NAME = 'XX_ORACLE_APPS_DNA_2'
AND FU2.USER_ID = FURGA2.USER_ID
AND FA2.APPLICATION_ID = FR2.APPLICATION_ID
AND FURGA2.RESPONSIBILITY_ID = FR2.RESPONSIBILITY_ID
AND FURGA2.RESPONSIBILITY_APPLICATION_ID = FA2.APPLICATION_ID
AND fsg2.security_group_id = furga2.security_group_id
-- AND furga.end_date IS NULL OR trunc(furga.end_date) > trunc(SYSDATE)
AND FURGA2.END_DATE IS NULL
);
--
--
BEGIN
FOR user_resp_details_rec IN src_user_resp_details
LOOP
BEGIN
--
FND_USER_PKG.ADDRESP (USERNAME => 'XX_ORACLE_APPS_DNA_2',
RESP_APP => USER_RESP_DETAILS_REC.APPLICATION_SHORT_NAME,
RESP_KEY => USER_RESP_DETAILS_REC.RESPONSIBILITY_KEY,
SECURITY_GROUP => USER_RESP_DETAILS_REC.SECURITY_GROUP_KEY,
DESCRIPTION => null,
start_date => SYSDATE,
end_date => NULL );
--
resp_count := resp_count + 1;
--
EXCEPTION
WHEN OTHERS THEN
--
DBMS_OUTPUT.put_line ( 'Error while Adding Responsibility: ' || SQLERRM );
DBMS_OUTPUT.put_line ( 'resp_app: ' || user_resp_details_rec.application_short_name );
DBMS_OUTPUT.put_line ( 'resp_key: ' || user_resp_details_rec.responsibility_key );
--
END;
END LOOP;
--
DBMS_OUTPUT.put_line (resp_count || ' Responsibilities Successfully Copied!!' );
--
COMMIT;
END;

Symfony and Doctrine using setParameters make result set empty

I can't understand why I have different results with this code:
The only thing I change token for setParameter.
The result is empty.
This works
$this->createQueryBuilder('t')
->select('t, c')
->leftJoin('t.documentos', 'c')
->where('t.flagStatus = :status')
->andWhere('c.flagStatus = :status')
->andWhere('t.idSecretaria in (:s)')
->andWhere('t.typedoc = 1')
->orderBy('c.tituloInformacao', 'ASC')
->setParameters([
'status' => true,
's' => 8,
])
->getQuery()
->execute();
But this won't work an empty result set is given.
$this->createQueryBuilder('t')
->select('t, c')
->leftJoin('t.documentos', 'c')
->where('t.flagStatus = :status')
->andWhere('c.flagStatus = :status')
->andWhere('t.idSecretaria in (:s)')
->andWhere('t.typedoc = :td')
->orderBy('c.tituloInformacao', 'ASC')
->setParameters([
'status' => true,
's' => 8,
'td' => 1,
])
->getQuery()
->execute();

Resources