SpringBatch& ORA-01792:表或视图中的最大列数为1000

时间:2016-08-19 08:05:32

标签: java sql spring oracle spring-batch

我开发了一个Spring批处理应用程序,它从6个oracle表中读取数据并进行处理。问题是读取超过1000列数据。这是通过在SQL Side执行ALTER session SET "_fix_control"='17376322:OFF';命令手动解决的,但我无法执行此命令弹簧批处理代码端。任何人都可以帮助学习如何使用spring batch执行ALTER session SET "_fix_control"='17376322:OFF'命令。

我必须在执行下面给出的select语句之前执行“ALTER session SET”_fix_control“='17376322:OFF'”命令:

<batch:job id="extract">
        <batch:step id="step1">
            <batch:tasklet>
                <batch:chunk reader="ItemReader"
                    processor="Processor" writer="ItemWriter"
                    commit-interval="1">
                </batch:chunk>
            </batch:tasklet>
        </batch:step>
    </batch:job> 
<bean id="ItemReader"
        class="org.springframework.batch.item.database.JdbcCursorItemReader" scope="step">
        <property name="dataSource" ref="dataSource" />
        <property name="sql">
            <value>
            <![CDATA[
 SELECT 
[1000+ Columns]
FROM #{jobParameters[table1]} D 
left join #{jobParameters[table2}  A on D.xyz=A.xyz
left join #{jobParameters[table3]} D2 on D.xyz=D2.xyz
left join #{jobParameters[table4]} A2 on D.xyz = A2.xyz
left join #{jobParameters[table5]} fed on D.xyz=fed.xyz
left join #{jobParameters[table6]} g on d.xyz=g.xyz
left join #{jobParameters[table7]} l on d.xyz=l.xyz

            ]]>
            </value>
        </property>

        <property name="rowMapper">
            <bean class="XXX.DataRowMapper" />
        </property>
    </bean>

2 个答案:

答案 0 :(得分:2)

您可以在发出set命令的数据库上添加登录触发器

CREATE OR REPLACE TRIGGER YOUR_DB_USER.SET_FIX_CONTROL_ON_LOGON
AFTER LOGON ON YOUR_DB_USER..SCHEMA
BEGIN
    EXECUTE IMMEDIATE 'ALTER session SET "_fix_control"=''17376322:OFF'''; 
END;

答案 1 :(得分:2)

您可以在数据源上设置它......

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${driverClassName}" />
<property name="url" value="${datasource.url}" />
<property name="username" value="#" />
<property name="password" value="#" />
<property name="connectionInitSqls" value="${datasource.initsql}" />
</bean>

然后在你的属性......

datasource.initsql=ALTER session SET "_fix_control"='17376322:OFF