1
Speak guys, I’m starting learning with BD Oracle, before I used Firebird. However I’m having a problem that I’m not able to solve. I can not include a new country by the system (java), if I insert by Sqldeveloper, it appears in the query. The error that appears when I try to include is the following:
java.sql.SQLException: ORA-00942: a tabela ou view não existe
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:440)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:837)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:445)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:523)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:193)
at oracle.jdbc.driver.T4CStatement.executeForDescribe(T4CStatement.java:852)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1153)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1275)
at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:1477)
at oracle.jdbc.driver.OracleStatementWrapper.executeQuery(OracleStatementWrapper.java:392)
at bd.Conexao.pegaGenerator(Conexao.java:50)
(...)
the line the error indicates to me, is :
public static Integer pegaGenerator(String generator)
{
try
{
Statement st = Conexao.getConexao().createStatement();
ResultSet rs = st.executeQuery("SELECT GEN_ID(" + generator + ", 1) FROM RDB$DATABASE");
rs.next();
return rs.getInt(1);
}
catch (Exception e)
{
e.printStackTrace();
JOptionPane.showMessageDialog(null, "Não foi possível obter o generator!");
return null;
}
}
The table in Oracle I created so:
CREATE TABLE Pais
(
ID_Pais INTEGER NOT NULL,
Nome_Pais VARCHAR(60) NOT NULL,
Sigla_Pais VARCHAR(3) NOT NULL,
Status_Pais CHAR(1) NOT NULL,
CONSTRAINT ID_Pais PRIMARY KEY (ID_Pais)
);
and for the tool I made Rigger
If you do "SELECT GEN_ID(" + Generator + ", 1) FROM PARENTS" does not work?
– igventurelli
I used to do this in Firebird to be oriented, then he would take all tables, this code I don’t need to repeat.
– Gustavo Santos
Voce can make a
select MAX([coluna]) + 1 from [tabela]
but I believe that Oracle does not have a functionGEN_ID()
equal to Firebird - the question of info. the oracle equivalent of the Firebird dummy tableRDB$DATABASE
isDUAL
– andrepaulo
Ah, I think I get it now (I don’t know Firebird). You want to generate an ID to use on
ID_Pais
. That’s it?– igventurelli