hi, i use to create API but have some problems. when i use it i can get only 1 row and get an error :
ORA-20001: The job you have entered already exists in this Business Group. Please enter a unique name for your job and an error: ORA-20001: HR_289477_JOB_GROUP_ID

for all other rows. here is my query.

declare
--
l_rows_processed number := 0; -- rows processed by api
l_commit_point number := 20; -- Commit after X successful rows
l_batch_run_number number;
l_dummy_line_id number;
l_job_id number;
l_job_definition_id number;
l_object_version_number number;
l_name varchar2(100);
--
l_business_group_id number;
l_name_combination_warning boolean;
l_orig_hire_warning boolean;
l_DUPLICATE_ORG_WARNING boolean := false;
l_clean_transfer number; -- 0 - clean; 1 - errors
--
-- select the next batch run number
--
cursor csr_batch_run_number is
select nvl(max(abm.batch_run_number), 0) + 1
from hr_api_batch_message_lines abm;
--
-- select all the applicant rows
--
cursor csr_tpa is
select
a.date_from,
a.date_to,
a.JOB_GROUP_ID,
b.segment1,
b.segment2
from HR.PER_JOBS@prod_link a,
HR.PER_JOB_DEFINITIONS@prod_link b
where a.job_definition_id = b.job_definition_id
and a.business_group_id = 81;

begin

-- open and fetch the batch run number

open csr_batch_run_number;
fetch csr_batch_run_number into l_batch_run_number;
close csr_batch_run_number;

-- open and fetch each temporary address row

for sel in csr_tpa loop
begin
-- create jobs in the HR Schema


hr_job_api.create_job
(P_VALIDATE => false
,P_BUSINESS_GROUP_ID => l_business_group_id
,P_DATE_FROM => sel.date_from
,P_COMMENTS => null
,P_DATE_TO => sel.date_to
,P_APPROVAL_AUTHORITY => null
,P_BENCHMARK_JOB_FLAG => 'N' --
,P_BENCHMARK_JOB_ID => null --
,P_EMP_RIGHTS_FLAG => 'N'
,P_JOB_GROUP_ID => sel.JOB_GROUP_ID
,P_ATTRIBUTE_CATEGORY => null
,P_ATTRIBUTE1 => null
,p_attribute2 => null
,p_attribute3 => null
,p_attribute4 => null
,p_attribute5 => null
,p_attribute6 => null
,p_attribute7 => null
,p_attribute8 => null
,p_attribute9 => null
,p_attribute10 => null
,p_attribute11 => null
,p_attribute12 => null
,p_attribute13 => null
,p_attribute14 => null
,p_attribute15 => null
,p_attribute16 => null
,p_attribute17 => null
,p_attribute18 => null
,p_attribute19 => null
,p_attribute20 => null
,P_JOB_INFORMATION_CATEGORY => null
,P_JOB_INFORMATION1 => null
,P_JOB_INFORMATION2 => null
,P_JOB_INFORMATION3 => null
,P_JOB_INFORMATION4 => null
,P_JOB_INFORMATION5 => null
,P_JOB_INFORMATION6 => null
,P_JOB_INFORMATION7 => null
,P_JOB_INFORMATION8 => null
,P_JOB_INFORMATION9 => null
,P_JOB_INFORMATION10 => null
,P_JOB_INFORMATION11 => null
,P_JOB_INFORMATION12 => null
,P_JOB_INFORMATION13 => null
,P_JOB_INFORMATION14 => null
,P_JOB_INFORMATION15 => null
,P_JOB_INFORMATION16 => null
,P_JOB_INFORMATION17 => null
,P_JOB_INFORMATION18 => null
,P_JOB_INFORMATION19 => null
,P_JOB_INFORMATION20 => null
,P_SEGMENT1 => sel.segment1
,P_SEGMENT2 => sel.segment2
,P_SEGMENT3 => null
,P_SEGMENT4 => null
,P_SEGMENT5 => null
,P_SEGMENT6 => null
,P_SEGMENT7 => null
,P_SEGMENT8 => null
,P_SEGMENT9 => null
,P_SEGMENT10 => null
,P_SEGMENT11 => null
,P_SEGMENT12 => null
,P_SEGMENT13 => null
,P_SEGMENT14 => null
,P_SEGMENT15 => null
,P_SEGMENT16 => null
,P_SEGMENT17 => null
,P_SEGMENT18 => null
,P_SEGMENT19 => null
,P_SEGMENT20 => null
,P_SEGMENT21 => null
,P_SEGMENT22 => null
,P_SEGMENT23 => null
,P_SEGMENT24 => null
,P_SEGMENT25 => null
,P_SEGMENT26 => null
,P_SEGMENT27 => null
,P_SEGMENT28 => null
,P_SEGMENT29 => null
,P_SEGMENT30 => null
,P_CONCAT_SEGMENTS => null
,P_LANGUAGE_CODE => null
,P_JOB_ID => l_JOB_ID
,P_OBJECT_VERSION_NUMBER => l_OBJECT_VERSION_NUMBER
,P_JOB_DEFINITION_ID => l_job_definition_id
,P_NAME => l_name
);

-- increment the number of rows processed by the api
l_rows_processed := l_rows_processed + 1;

-- determine if the commit point has been reached
if (mod(l_rows_processed, l_commit_point) = 0) then
-- the commit point has been reached therefore commit
commit;
end if;
exception
when others then
--
-- An API error has occurred
-- Note: As an error has occurred only the work in the last API
-- call will implicitly rolled back. The uncommitted work
-- done by previous API calls will not be affected.
-- If the error is ora-20001 the fnd_message.get function
-- will retrieve and substitute all tokens for the short
-- and extended message text.
-- If the error is not ora-20001 null will be return.
--
hr_batch_message_line_api.create_message_line
(p_batch_run_number => l_batch_run_number
,p_api_name => 'hr_job_api.create_job'
,p_status => 'F'
,p_error_number => sqlcode
,p_error_message => sqlerrm || ' ' || l_name
,p_extended_error_message => fnd_message.get
,p_line_id => l_dummy_line_id);
end;
end loop;

-- commit any final rows
commit;
end;

/

-- error logs
-- select * from hr_api_batch_message_lines;

-- delete from hr_api_batch_message_lines;


if you can, help me pls. Thx for reading