PL/SQL: ORA-04063: view "OPS$DTEPROD.DTE_BLMB_TRD_ACCT_VW" - oracle

I have a view, which created (ORACLE)
CREATE OR REPLACE FORCE VIEW "OPS$DTEPROD"."DTE_BLMB_TRD_ACCT_VW"
("BB_TRD_ACCT", "DESCRIPTION", "ICI_TRD_ACCT") AS
select rtrim(STRBK_BOOK_NAME) bb_trd_acct,
rtrim(STRBK_DESCRIPTION) description,
trading_acct ici_trd_acct
from spider.sp_struct_books#spdn b1
, dte_trading_acct
where substr(rtrim(STRBK_BOOK_NAME),1,2)=ltrim(rtrim(fits_trading_Acct))
and strbk_last_update_date =
(select max(strbk_last_update_date)
from spider.sp_struct_books#spdn b2
where b2.strbk_book_number = b1.strbk_book_number)
In the package, when I compile it shows me an error
328/117 PL/SQL: ORA-04063: view "OPS$DTEPROD.DTE_BLMB_TRD_ACCT_VW" has
errors
Could you please help me to find the reason?
Thanks
Errors for PACKAGE BODY RATES_2DTE:
LINE/COL ERROR
-------- -----------------------------------------------------------------
328/1 PL/SQL: SQL Statement ignored
328/117 PL/SQL: ORA-04063: view "OPS$DTEPROD.DTE_BLMB_TRD_ACCT_VW" has
errors

Please execute following query with same user which get the outlined error:
Select * from user_errors where name like 'OPS$DTEPROD.DTE_BLMB_TRD_ACCT_VW';
This will give you errors in the view. You can post output for further investigations.
Regards
Abhi

In order to solve such problem I have to work with our DBA. Only they can give access to this database from development server. On production we have everything done.
Thank you all for trying to help me

Their are two probabilities :
1) As another member (#xQbert) suggested - user who is used to created view do not have accesses to table over dB link.
2) Database, used in database link, is not accessible.
Solution:
1) Please execute following statement by same user which is trying to select from view:
Select count(*) from spider.sp_struct_books#spdn ;
This should give same error as original error.
We want to check is read access to destination table is in place.
2) From server/command prompt on database host, where view is created, execute following :
tnsping spdn (or tnsping <database name usec by db link>)
OR
sqlplus <Username>/<Password>#spdn (or <database name usec by db link>)
We want to check if destination database on dBlink is reachable.
Abhi

Related

Why Can't PDI find/run my package stored procedure?

community! This is my first question, please go easy on me! :)
I have an ETL process on PDI to orchestrate calls on procedures stored in a package in Oracle.
Some procedures are ready and run normally on PL/SQL Developer.
When I call them using pentaho, either using the job 'SQL' or the transformations 'Execute SQL Script' or 'Call DB procedure' I always get an error related to "can't find the procedure", like: "ORA-00904: "PKG_CARGA_DIARIA_SABARA"."FUN_HELLO_WORLD": invalid identifier" or "ORA-06550: line 1, column 13:
PLS-00201: identifier 'PKG_CARGA_DIARIA_SABARA.FUN_HELLO_WORLD' must be declared".
Please, what am I doing wrong?
enter image description here
enter image description here
enter image description here
EDIT 1: I'm using the user that created the package both to test it in PL/SQL Developer and to connect to the database in PDI.
If I run your code, I get - no surprise - the same message:
SQL> select "PKG_CARGA_DIARIA_SABARA"."FUN_HELLO_WORLD" from dual;
select "PKG_CARGA_DIARIA_SABARA"."FUN_HELLO_WORLD" from dual
*
ERROR at line 1:
ORA-00904: "PKG_CARGA_DIARIA_SABARA"."FUN_HELLO_WORLD": invalid identifier
SQL>
It means that function in that package (which means the package itself) isn't accessible to me. Of course it isn't, I don't have it in my schema. Looks like you don't have it either.
Saying that it works in PL/SQL Developer, I suppose you're connected as package's owner. If user - who tries to call that function - connected to the database in PDI (whatever it is, I don't know/use it) isn't the same as the one you used in PL/SQL Developer and it wasn't granted EXECUTE privilege on the package, then it can't "see" nor execute it.
Therefore:
try to connect as package's owner
if you must connect as someone else, let owner grant EXECUTE privilege, while you should (in PDI) precede package name with the owner name
Found it here! Will post so that anyone can use the answer.
PDI Doesn't automatically consider the schema from the database connection user, you have to specifically add it to your code inside the SQL job.
So: "BEGIN .<procedure name; END;" yelds the error, even though I was running with the procedure and package owner.
And: "BEGIN ..<procedure name; END;" will work it out just fine.
Hope it helps someone, tks!

Unable to create a trigger in Oracle SQL

I want to create a trigger but it is tainted by a warning: trigger created with compilation errors. The query that I am running is:
CREATE OR REPLACE TRIGGER Audit_Salaries
AFTER UPDATE ON EMPLOYEES
FOR EACH ROW
BEGIN
IF (:NEW.Salary > :OLD.Salary*1.20) THEN
INSERT INTO Salary_Audit (EmployeeID, OldSalary, NewSalary,Username, ChangeDate)
VALUES (:NEW.employee_id, :OLD.Salary,:NEW.Salary, user, sysdate);
END IF;
END;
/
Warning: Trigger created with compilation errors.
And this is the result that I am getting:
Warning: Trigger created with compilation errors.
I tried reading other similar answers but the solutions that are given there already exist in mine(syntax).
Due to this, when I log into the different user and run the query, it says the trigger is at fault or not created properly, re-validation failed.
I expect the trigger to be created without any compilation errors along with the understanding of what is wrong in my query.
To see the details of the compilation error, you can query system view USER_ERRORS (or DBA_ERRORS):
SELECT * FROM USER_ERRORS WHERE NAME = 'AUDIT_SALARIES';
I cannot reproduce the error that you are getting, your code compiles successfully when I run it on 11gR2 and 18c. I can only imagine that there is an error in the column names of source table employees or target table salary_audit.
Demo on DB Fiddle
You can see the compilation error using DBA_ERRORS.
SELECT * FROM DBA_ERRORS WHERE NAME = 'AUDIT_SALARIES';
You tagged SQL Developer.
Are you using SQL Developer?
Because if you are...
We automatically do a 'show errors' for you on a compile when errors/warnings are returned. You can also see the compiler messages on the 'Compiler' tab - this should open automatically when you run it.
If you're not seeing this, I'm guessing you're on some version of SQL Developer where a bug is preventing that from happening, but I'm not aware of a version where that would be true.
Try this it will solve you query:
SELECT * FROM DBA_ERRORS WHERE NAME = 'AUDIT_SALARIES'
OR
SELECT * FROM USER_ERRORS WHERE NAME = 'AUDIT_SALARIES';

Running query cannot connect to vendort's database, even dblink exists

I have a simple query, which I run on sqldeveloper on put database, but it select data from different vendor database. We have db_link created. but I run, as in my Pro C program:
select some_files from mytable trd, vendordbname.vendortable
where(condition)
and I get an error:
ORA-00942: table or view does not exist
00942. 00000 - "table or view does not exist"
*Cause:
*Action:
Error at Line: 25 Column:
What kind of solution I have to find, to make it run? Use dblink name? or something else? I will appreciate any possible help
Thanks
ok, when it runs with Pro C, everything sets up on UNIX and sqlplus.
When I run it from sqldeveloper I have to add the vendor host name
select some_files from mytable trd, vendordbname.vendortable#vendorhost
where(condition)

How to solve : SQL Error: ORA-00604: error occurred at recursive SQL level 1

When I'm trying to drop table then I'm getting error
SQL Error: ORA-00604: error occurred at recursive SQL level 2
ORA-01422: exact fetch returns more than requested number of rows
00604. 00000 - "error occurred at recursive SQL level %s"
*Cause: An error occurred while processing a recursive SQL statement
(a statement applying to internal dictionary tables).
*Action: If the situation described in the next error on the stack
can be corrected, do so; otherwise contact Oracle Support.
One possible explanation is a database trigger that fires for each DROP TABLE statement. To find the trigger, query the _TRIGGERS dictionary views:
select * from all_triggers
where trigger_type in ('AFTER EVENT', 'BEFORE EVENT')
disable any suspicious trigger with
alter trigger <trigger_name> disable;
and try re-running your DROP TABLE statement
I noticed following line from error.
exact fetch returns more than requested number of rows
That means Oracle was expecting one row but It was getting multiple rows. And, only dual table has that characteristic, which returns only one row.
Later I recall, I have done few changes in dual table and when I executed dual table. Then found multiple rows.
So, I truncated dual table and inserted only row which X value. And, everything working fine.
I know the post is old and solved, but maybe someone is facing or will face my situation, so I want to leave the aquired knowledge here, after deal with the error for a week. I was facing the error: "ORA-00604: error occurred at recursive SQL level 1" , but with the internal error: " ORA-06502: error: character string buffer too smal numeric or value", this happened only when I try to logon the database, and using an specific driver, trying to connect from an Visual Studio C# application, the weirdest thing on that moment was that I connect from SQLDeveloper or TOAD and everything worked fine.
Later I discovered that my machine name had this format "guillermo-aX474b5", then I proceed to rename it like this "guillermo" without the "-" and the other stuff, and it worked!! Looks like in some drivers and situations, ORACLE Database does'nt like the "-" in the LogOn connection.
Hope it helps!

Show compilation warnings in Intellij working with Oracle and PL/SQL

This code generates a Warning: Trigger created with compilation errors. (if for example the column doesn't exist) in iSQL*Plus, but not when executed in the console in Intellij.
CREATE TRIGGER triggerName
INSTEAD OF INSERT ON Table
REFERENCING NEW AS variabel
BEGIN
SELECT
COUNT(*)
INTO variabel
FROM Table
WHERE Table.column = 1;
END;
After I have executed the above I can do SHOW ERRORS in iSQL*Plus and get something like PL/SQL: ORA-00904: "TABLE"."COLUMN": invalid identifier. Trying to do SHOW ERRORS in Intellij leaves me with the SHOW keyword underlined in red which prevents me from executing it.
Is there anyway to have this iSQL*Plus functionality in Intellij?
Using ALL_ERRORS/USER_ERRORS table should help you see the errors, wherever you go!
SELECT * FROM ALL_ERRORS WHERE NAME = 'TRIGGERNAME'
SHOW ERRORS is an iSQL*Plus only feature. It would implicitly query the above table and print the results for us.
I see some plugins available for intellij support. Like one here. They would be using similar approach of SHOW ERRORS.

Resources