liquibase Oracle ORA-00942 - oracle

when calling liquibase migrate, generatechangelog, etc... with an Oracle database , we allways get the ORA-00942 error when liquibase calls the oracle jdbcdriver for metadata
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:439)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:395)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:802)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:436)

Found the issue by tracing the logging in the ojdbc_g driver. It turns out that getSchemas() in the jdbcdriver queries ´ALL_USERS` view in Oracle
DatabaseMetaData metadata=conn.getMetaData();
ResultSet rs2=metadata.getSchemas();
SELECT username AS table_schem,null as table_catalog FROM all_users ORDER BY table_schem
ORA-00942: table or view does not exist
In our database, ALL_USERS view does not exist, so I created the view again in the standard Oracle way
CREATE OR REPLACE FORCE VIEW "ALL_USERS" ("USERNAME", "USER_ID", "CREATED")
...

Related

Oracle SQL Auto-updating Table From a Different Database

I have two tables from different database, db1.names and db2.names_rep. db1.names is constantly getting new data and I need it to reflect in db2.names_rep.
I've created a dblink connecting for db1 in db2 named dblink_db1.
CREATE DATABASE LINK dblink_db1
CONNECT TO user IDENTIFIED BY pass
USING '(DESCRIPTION=
(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))
(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=SID)))';
and a trigger that calls the db1.names table
create or replace trigger "names_trigger"
after insert or update or delete on "names#dblink_db1"
for each row
begin
if inserting then
insert into "names_rep" (name_id, student_names)
values (:NEW.name_id, :NEW.student_names);
elsif updating then
update "names_rep"
set name_id=:NEW.name_id, student_names=:NEW.student_names
where name_id=:NEW.name_id;
elsif deleting then
delete from "names_rep"
where name_id=:OLD.name_id;
end if;
end;
The dblink is working as i can invoke this query successfully in db2
select * from names#dblink_db1
I'm receiving an error that says this
Error report: ORA-00942: table or view does not exist
00942. 00000 - "table or view does not exist"
*Cause:
*Action:
Lastly, I've read about Oracle Streams. Is that an alternative to Triggers? I'm hoping I don't have to specify each operation as to what is done in Trigger
You are trying to create a trigger in database db2 on a table in db1. I'm not sure that's possible.
I think the trigger needs to be created in db1, and to insert/update/delete rows over a link to db2.

Referring to objects(tables) in other schema or user in Oracle procedure

Am accessing table data from other schema and inserting into current schema table in oracle procedure, but am unable to compile the procedure getting error "Error(5,27): PL/SQL: ORA-00942: table or view does not exist".
But where as when I select data from table(in other schema) directly am able to fetch the data but not in procedure. I have all required permissions as well.
Below is the procedure.
CREATE OR REPLACE PROCEDURE TEST_SCHEMA
IS
BEGIN
INSERT INTO table1
SELECT * FROM Other_User_Schema.Table2
COMMIT;
END;
It seems that you acquired privileges to select data from other_user_schema.table2 via role. If that's so, grant that privilege directly to your user because that won't work in named PL/SQL procedures.

Can we get "ORA-00942: table or view does not exist" error if the user is not able to log into the DB?

My application is giving the "ORA-00942: table or view does not exist" error when in prod environment. Locally it works just fine(when tested locally I am accessing staging DB). On checking the DB in prod I found tables to be there but we have still not populated the values.
To answer your question, no. You cannot receive an ORA-00942 if you are not even connected to the database.
To address your further comments it is probably a matter of properly identifying the table and schema it is in.
conn system/manager;
grant select on hr.employees to scott;
conn scott/scott;
select * from employees;
ORA-00942: table or view does not exist
select * from hr.employees;
<return data>
Alternatively you can create a synonym for the table in the scott schema:
create or replace synonym scott.employees for hr.employees;
This will allow the failed query to succeed as the scott schema has an object called employees in its scope.

Schema name prefix issue in SQL query

I have WMADMIN schema. This schema is configured as connection credential in websphere datasource.
I have table in other schema/user OCS_JOBS. But the problem is my application looking for the table in WMADMIN schema.
It looks i need to prefix schemaname OCS_JOBS in SQL query to run them.
Is there any other way to run the SQL query the table which is in other user/schema without prefixing the other schema name
You can create a SYNONYM see it here: http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_7001.htm

Select BigSerial Column Data from Informix Table

The scenario is like that. User will specify a database table name and the system will retrieve and display all the data stored in the specified informix database table.
Class.forName("com.informix.jdbc.IfxDriver");
Connection conn = DriverManager.getConnection(connUrl)
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select * from an_ifx_table");
The an_ifx_table is any table name specified by user. The problem is there is a column defined with BigSerial data type. So, the code will always throw an exception:
java.sql.SQLException: bigserial
at com.informix.jdbc.IfxSqli.a(IfxSqli.java:3204)
at com.informix.jdbc.IfxSqli.E(IfxSqli.java:3518)
at com.informix.jdbc.IfxSqli.dispatchMsg(IfxSqli.java:2353)
at com.informix.jdbc.IfxSqli.receiveMessage(IfxSqli.java:2269)
at com.informix.jdbc.IfxSqli.executeStatementQuery(IfxSqli.java:1428)
at com.informix.jdbc.IfxSqli.executeStatementQuery(IfxSqli.java:1401)
at com.informix.jdbc.IfxResultSet.a(IfxResultSet.java:204)
As which table the system is retrieving the data from is going to be specified by user, we can't skip or cast the column with BigSerial data type.
Any suggestion to handle this scenario?
I have just created table with SERIAL8 column, filled it with some data and I can read all data from ResultSet.
Maybe your JDBC driver is old?
I use JDBC driver from JDBC.3.50.JC5.tar. You can also try JDBC-ODBC bridge. Install Informix ClientSDK, create ODBC source and then as driver use:
sun.jdbc.odbc.JdbcOdbcDriver
and as connUrl:
jdbc:odbc:[ODBC_source_name]
On my Windows machine I use clientsdk.3.50.TC5.WIN.zip, and on Linux I use clientsdk.3.50.UC5.LINUX.tar

Resources