-
1. Re: Dynamic sql with JbdcItemReader/JbdcItemWriter
cfang Feb 2, 2017 1:11 PM (in response to joao.santana)When starting a job execution, can you pass in a job parameter to specify the sql, and the job.xml can reference that job parameter.
Or if only part of the sql statement diffs in each job execution, you can just substitute part of the sql value.
jobParameters.setProperty("sql", "select * from PERSON");
or
jobParameters.setProperty("tableName", "PERSON_001");
<job id="org.jberet.support.io.JdbcReaderTest" xmlns="http://xmlns.jcp.org/xml/ns/javaee" version="1.0">
<step id="org.jberet.support.io.JdbcReaderTest.step1">
<chunk item-count="100">
<reader ref="jdbcItemReader">
<properties>
<property name="beanType" value="#{jobParameters['readerBeanType']}"/>
<property name="sql" value="#{jobParameters['sql']}"/>Or,
<property name="sql" value="select * from #{jobParameters['tableName']}"/>
-
2. Re: Dynamic sql with JbdcItemReader/JbdcItemWriter
joao.santana Feb 2, 2017 3:24 PM (in response to cfang)OK.
But my job is scheduled... how its works on a scheduled context?
-
3. Re: Dynamic sql with JbdcItemReader/JbdcItemWriter
cfang Feb 2, 2017 3:36 PM (in response to joao.santana)The scheduler, as the batch client, should be able to add job parameters when starting a job execution. There may be some ways to configure the scheduler.
-
4. Re: Dynamic sql with JbdcItemReader/JbdcItemWriter
joao.santana Feb 4, 2017 8:14 AM (in response to cfang)ok. thanks