简体   繁体   中英

Informix java.sql.SQLException: Column (…) not found in any table in the query (or SLV is undefined)

The query below is working without any problems in my java based sql Editor:

      begin work;
create SEQUENCE if not exists zahlpaketcounter start 1;
select zahlpaketcounter.nextval as counter,*
 from (
SELECT 
firma_nr
,zahlpaket.nummer
,zahlpaket.bezeichnung
,personenkonto.kontonummer
,personenkonto.bezeichnung
,zahlbewegung.op_nr
,zahlbewegung.zahlbetrag_druck
,fibu_beleg.archiv_nr
FROM integris.zahlbewegung
join zahlpaket on zahlbewegung.zahlpaket_id=zahlpaket.zahlpaket_id
join integris.personenkonto on zahlbewegung.personenkonto_id=personenkonto.personenkonto_id
join integris.opbewegung on  zahlbewegung.opbewegung_id=opbewegung.opbewegung_id
join integris.fibu_beleg on opbewegung.fibu_beleg_id=fibu_beleg.fibu_beleg_id
join integris.firma on zahlpaket.firma_id = firma.firma_id
where 1=1
and zahlbewegung.zahlbetrag_druck >=0
order by nummer,personenkonto.kontonummer,zahlbewegung.op_nr
);
drop sequence zahlpaketcounter;
commit work;

when I use in it java:

        sql=getTextResource(this,"sql/getZahlläufe.sql");
        fibustmt.execute(sql);

the execute method fails with:

 java.sql.SQLException: Column (zahlpaketcounter) not found in any table in the query (or SLV is undefined).

Why? Any Ideas?

Seems not possible to use multiple statements with execute(). You should use addBatch() and executeBatch() but not with a SELECT. It works with 3 execute().

String sqlQ="create SEQUENCE if not exists zahlpaketcounter start 1";
PreparedStatement pstmt = cnx.prepareStatement();
pstmt.execute();
sqlQ="SELECT ...";
pstmt = cnx.prepareStatement();
pstmt.execute();
sqlQ="drop SEQUENCE if exists zahlpaketcounter";
pstmt = cnx.prepareStatement();
pstmt.execute();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM