Spring Batch 和 ORA-01792:table 或视图中的最大列数为 1000
SpringBatch & ORA-01792: maximum number of columns in a table or view is 1000
我开发了一个 spring 批处理应用程序,它从 6 个 oracle 表中读取数据并进行处理。问题是读取了超过 1000 列的数据。这是通过在 SQL 端执行 ALTER session SET "_fix_control"='17376322:OFF';
命令手动解决的,但我无法在 spring 批处理代码端执行此命令。任何人都可以帮助如何使用 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>
您可以在发出设置命令的数据库上添加登录触发器
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;
可以在数据源上设置...
<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
我开发了一个 spring 批处理应用程序,它从 6 个 oracle 表中读取数据并进行处理。问题是读取了超过 1000 列的数据。这是通过在 SQL 端执行 ALTER session SET "_fix_control"='17376322:OFF';
命令手动解决的,但我无法在 spring 批处理代码端执行此命令。任何人都可以帮助如何使用 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>
您可以在发出设置命令的数据库上添加登录触发器
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;
可以在数据源上设置...
<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