Joachim Weiß
Joachim Weiß

Reputation: 226

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?

Upvotes: 1

Views: 1654

Answers (1)

jacques
jacques

Reputation: 240

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();

Upvotes: 1

Related Questions