I'm writing a little java program to write data in a AS/400 DB2 table via jdbc (db2jcc.jar version 1.0.581) and a trigger is associated to the INSERT operation. This trigger works on various tables associated with libraries different from that (jdta73p10) which contains my table (f4104).
Follows the code I use to establish connection and read data that perfectly runs.
import java.sql.*;
import com.ibm.db2.jcc.*;
public class ProvaNUMEAN13 {
public static void main(String[] args) throws SQLException, ClassNotFoundException {
DB2DataSource dbds = new DB2DataSource();
dbds.setDriverType(4);
dbds.setServerName("a60d45bb");
dbds.setPortNumber(446);
dbds.setDatabaseName("prodgrp");
dbds.setDescription("Prova collegamento");
dbds.setUser("XXXXX");
dbds.setPassword("XXXXX");
Connection con = dbds.getConnection();
Statement stmtNum = con.createStatement();
stmtNum.executeQuery("select * from INTERFACCE.NUMEAN13");
ResultSet rs = stmtNum.getResultSet();
rs.next();
System.out.println("Valore numeratore: " + rs.getString("E13EAN"));
System.out.println("Tipo numeratore: " + rs.getString("K13KEY"));
stmtNum.close();
Statement stmtAnag = con.createStatement();
stmtAnag.executeQuery("select * from jdta73p10.f4101lb where IMLITM = " + "'" + args[0] + "'");
ResultSet rsAna = stmtAnag.getResultSet();
int idCodice = 0;
if (!rsAna.next()) {
System.out.println("Il codice " + args[0] + " non esiste in anagrafica!");
} else {
idCodice = rsAna.getInt("IMITM");
System.out.println("idCodice per " + args[0] + ": " + Integer.toString(idCodice));
Statement stmtQEAN = con.createStatement();
stmtQEAN.executeQuery("select IVALN, IVCITM, IVLITM, IVDSC1 from jdta73p10.f4104 where IVXRT = 'B ' and IVALN = '8000000000000'");
ResultSet rsQEAN = stmtQEAN.getResultSet();
if (rsQEAN.next()) {
System.out.println("Codice EAN per " + args[0] + " giĆ presente: " + rsQEAN.getString("IVALN"));
System.out.println("Valore EAN13: " + rsQEAN.getString("IVCITM"));
System.out.println("Risultato ricerca per EAN13: " + rsQEAN.getString("IVLITM")+" - "+rsQEAN.getString("IVDSC1"));
}
}
}
}
Problem is when I try to execute an INSERT operation (like that below); an error is generated in AS/400 due to trigger execution.
stmtQEAN.execute("insert into jdta73p10.f4104 (IVXRT,IVITM,IVCITM,IVDSC1,IVALN,IVLITM) values ('B ','18539','8000000000000','Prodotto PROVA','8000000000000','ABABABAB')");
This is the error AS/400 side:
Message ID . . . . . . : RNQ0211 Severity . . . . . . . : 99
Message type . . . . . : Inquiry
Date sent . . . . . . : 08/01/15 Time sent . . . . . . : 10:01:31
Message . . . . : Error occurred while calling program or procedure *LIBL/PRHWRAPUSE (C G D F). Cause . . . . . : RPG procedure TRG_F4104A in program INTERFACCE/TRG_F4104A at statement 152 attempted to call program or procedure *LIBL/WS_MATERI, but was unable to access the program or procedure, the library, or a required service program. If the name is *N, the call was a bound call by procedure pointer.
Recovery . . . : Check the job log for more information on the cause of the error and contact the person responsible for program maintenance. Possible choices for replying to message . . . . . . . . . . . . . . . :
D -- Obtain RPG formatted dump.
S -- Obtain system dump.
My question is: how can I specify the other libraries that trigger need? In a old version of my tools (written in Delphi) I used the Client/Access ODBC where there was a special field where you can enter additional libraries but now I don't know how to do.