java – ORA-01733(此处不允许使用虚拟列)数据库更新后

我们的一个数据库已从Oracle 9i更新为11g.从那时起,我们的一个程序在尝试通过视图更新列时不断出现错误.我们也将JDBC驱动程序更新为11g.风景:CREATE OR REPLACE VIEW UIV ASSELECT(SELECT FIR_KO_KREIS FROM FIR...

我们的一个数据库已从Oracle 9i更新为11g.从那时起,我们的一个程序在尝试通过视图更新列时不断出现错误.我们也将JDBC驱动程序更新为11g.

风景:

CREATE OR REPLACE VIEW UIV AS
SELECT
(SELECT FIR_KO_KREIS FROM FIRMA
WHERE FIR_KONZERN_NR = TRCO_KONZERN_NR
AND FIR_FIRMA_NR = TRCO_FIRMA_NR) UIVNFIRMA,
UIVAAENNKZ UIVAAENKZ,
UVVOL,
UVCLS,
UVID1,
UVID2,
UVID3,
UVID4,
UVID5,
UVID6,
TO_NUMBER(TRIM(UVGJ)) UVGJ,
UVEINH,
TO_NUMBER(TRIM(UVW00)) UVW00,
TO_NUMBER(TRIM(UVW01)) UVW01,
TO_NUMBER(TRIM(UVW02)) UVW02,
TO_NUMBER(TRIM(UVW03)) UVW03,
TO_NUMBER(TRIM(UVW04)) UVW04,
TO_NUMBER(TRIM(UVW05)) UVW05,
TO_NUMBER(TRIM(UVW06)) UVW06,
TO_NUMBER(TRIM(UVW07)) UVW07,
TO_NUMBER(TRIM(UVW08)) UVW08,
TO_NUMBER(TRIM(UVW09)) UVW09,
TO_NUMBER(TRIM(UVW10)) UVW10,
TO_NUMBER(TRIM(UVW11)) UVW11,
TO_NUMBER(TRIM(UVW12)) UVW12,
TO_NUMBER(TRIM(UVW13)) UVW13,
NULL UVK01,
NULL UVK02,
NULL UVK03,
NULL UVK04,
NULL UVK05,
NULL UVK06,
NULL UVK07,
NULL UVK08,
NULL UVK09,
NULL UVK10,
NULL UVK11,
NULL UVK12,
NULL UVK13
FROM CO_BUCH;

我们的程序选择UIVAAENKZ为1的所有记录.此列应在java ResultSet中更新并设置为0.

在resultSet.updateRow();我们用oracle代码01733得到一个例外.有人知道我们能解决这个问题吗?它与Oracle 9i一起运行良好.

编辑:首先,我们将所有选定的条目写入文件.之后我们回滚结果集(extractedData)并更新行:

extractedData.beforeFirst();
while (extractedData.next()) {
    extractedData.updateString("UIVAAENKZ", "0");
    extractedData.updateRow();
}

请注意,视图中的列名称与原始表UIVAAENKZ UIVAAENNKZ中的列略有不同.但正如我所说,这不是问题.

原始表:

create table CO_BUCH
(
  uvvol              VARCHAR2(4),
  uvcls              VARCHAR2(4),
  uvid1              VARCHAR2(15),
  uvid2              VARCHAR2(15),
  uvid3              VARCHAR2(15),
  uvid4              VARCHAR2(15),
  uvid5              VARCHAR2(15),
  uvid6              VARCHAR2(15),
  fill001            VARCHAR2(1),
  uvgj               VARCHAR2(3),
  uveinh             VARCHAR2(4),
  fill002            VARCHAR2(1),
  uvw00              VARCHAR2(16),
  fill003            VARCHAR2(1),
  uvw01              VARCHAR2(16),
  fill004            VARCHAR2(1),
  uvw02              VARCHAR2(16),
  fill005            VARCHAR2(1),
  uvw03              VARCHAR2(16),
  fill006            VARCHAR2(1),
  uvw04              VARCHAR2(16),
  fill007            VARCHAR2(1),
  uvw05              VARCHAR2(16),
  fill008            VARCHAR2(1),
  uvw06              VARCHAR2(16),
  fill009            VARCHAR2(1),
  uvw07              VARCHAR2(16),
  fill010            VARCHAR2(1),
  uvw08              VARCHAR2(16),
  fill011            VARCHAR2(1),
  uvw09              VARCHAR2(16),
  fill012            VARCHAR2(1),
  uvw10              VARCHAR2(16),
  fill013            VARCHAR2(1),
  uvw11              VARCHAR2(16),
  fill014            VARCHAR2(1),
  uvw12              VARCHAR2(16),
  fill015            VARCHAR2(1),
  uvw13              VARCHAR2(16),
  fill016            VARCHAR2(13),
  trco_konzern_nr    NUMBER,
  trco_firma_nr      NUMBER,
  trco_betrieb_nr    NUMBER,
  trco_tras_beleg_nr NUMBER,
  trco_senden_datum  DATE,
  trco_ausgabe       VARCHAR2(1000),
  uivaaennkz         VARCHAR2(1),
  uivaersben         VARCHAR2(10),
  uivdersdat         DATE,
  uivaaenben         VARCHAR2(10),
  uivdaendat         DATE,
  uivndsasta         NUMBER(2),
  uivnfirma          NUMBER
)

编辑2:

SELECT COLUMN_NAME的OUptut,DATA_TYPE,DATA_DEFAULT,HIDDEN_COLUMN,VIRTUAL_COLUMN来自USER_TAB_COLS WHERE TABLE_NAME =’CO_BUCH’ORDER BY COLUMN_ID;

UVVOL;VARCHAR2;<null>;NO;NO
UVCLS;VARCHAR2;<null>;NO;NO
UVID1;VARCHAR2;<null>;NO;NO
UVID2;VARCHAR2;<null>;NO;NO
UVID3;VARCHAR2;<null>;NO;NO
UVID4;VARCHAR2;<null>;NO;NO
UVID5;VARCHAR2;<null>;NO;NO
UVID6;VARCHAR2;<null>;NO;NO
FILL001;VARCHAR2;<null>;NO;NO
UVGJ;VARCHAR2;<null>;NO;NO
UVEINH;VARCHAR2;<null>;NO;NO
FILL002;VARCHAR2;<null>;NO;NO
UVW00;VARCHAR2;<null>;NO;NO
FILL003;VARCHAR2;<null>;NO;NO
UVW01;VARCHAR2;<null>;NO;NO
FILL004;VARCHAR2;<null>;NO;NO
UVW02;VARCHAR2;<null>;NO;NO
FILL005;VARCHAR2;<null>;NO;NO
UVW03;VARCHAR2;<null>;NO;NO
FILL006;VARCHAR2;<null>;NO;NO
UVW04;VARCHAR2;<null>;NO;NO
FILL007;VARCHAR2;<null>;NO;NO
UVW05;VARCHAR2;<null>;NO;NO
FILL008;VARCHAR2;<null>;NO;NO
UVW06;VARCHAR2;<null>;NO;NO
FILL009;VARCHAR2;<null>;NO;NO
UVW07;VARCHAR2;<null>;NO;NO
FILL010;VARCHAR2;<null>;NO;NO
UVW08;VARCHAR2;<null>;NO;NO
FILL011;VARCHAR2;<null>;NO;NO
UVW09;VARCHAR2;<null>;NO;NO
FILL012;VARCHAR2;<null>;NO;NO
UVW10;VARCHAR2;<null>;NO;NO
FILL013;VARCHAR2;<null>;NO;NO
UVW11;VARCHAR2;<null>;NO;NO
FILL014;VARCHAR2;<null>;NO;NO
UVW12;VARCHAR2;<null>;NO;NO
FILL015;VARCHAR2;<null>;NO;NO
UVW13;VARCHAR2;<null>;NO;NO
FILL016;VARCHAR2;<null>;NO;NO
TRCO_KONZERN_NR;NUMBER;<null>;NO;NO
TRCO_FIRMA_NR;NUMBER;<null>;NO;NO
TRCO_BETRIEB_NR;NUMBER;<null>;NO;NO
TRCO_TRAS_BELEG_NR;NUMBER;<null>;NO;NO
TRCO_SENDEN_DATUM;DATE;<null>;NO;NO
TRCO_AUSGABE;VARCHAR2;<null>;NO;NO
UIVAAENNKZ;VARCHAR2;<null>;NO;NO
UIVAERSBEN;VARCHAR2;<null>;NO;NO
UIVDERSDAT;DATE;<null>;NO;NO
UIVAAENBEN;VARCHAR2;<null>;NO;NO
UIVDAENDAT;DATE;<null>;NO;NO
UIVNDSASTA;NUMBER;<null>;NO;NO
UIVNFIRMA;NUMBER;<null>;NO;NO

解决方法:

我们终于找到了解决方案.虽然它可能不漂亮,但它很有效,而且很简单.

问题是视图中的以下列是从不同的表中选择的:

(SELECT FIR_KO_KREIS FROM FIRMA
WHERE FIR_KONZERN_NR = TRCO_KONZERN_NR
AND FIR_FIRMA_NR = TRCO_FIRMA_NR) UIVNFIRMA

当我们在导出期间没有选择此列时,一切正常.不幸的是我们需要这个专栏,所以我们必须提出一个不同的解决方案.

围绕整个选定数据的附加选择消除了问题:

CREATE OR REPLACE VIEW UIV AS
SELECT * FROM (
SELECT
(SELECT FIR_KO_KREIS FROM FIRMA
WHERE FIR_KONZERN_NR = TRCO_KONZERN_NR
AND FIR_FIRMA_NR = TRCO_FIRMA_NR) UIVNFIRMA,
UIVAAENNKZ UIVAAENKZ,
UVVOL,
UVCLS,
UVID1,
.
.
.
FROM CO_BUCH);

本文标题为:java – ORA-01733(此处不允许使用虚拟列)数据库更新后

基础教程推荐