DVSYS object(package body) invalid - oracle

I am using oracle 12c oracle database vault with opt=false but still having invalid object for dvsys user.
I have run
catalog.sql
catproc.sql
utlrp.sql
but still not get validate this object.

It looks like you have no errors, but object invalidated because one of its reference changed. It sometimes happens.
2 things you may try:
just call its description.
SQL> desc DVSYS.DV$CODE
use dbms_utility to compile the schema where some objects are invalid (you may need to connect as sysdba):
SQL> begin dbms_utility.compile_schema('DVSYS', FAlSE); end;
/

Related

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';

SAP BO - Report from stored proc

I'm trying to get SAP Business Objects to get a report off of a stored procedure. I had no luck, so I'm now just trying with an example/tutorial of how to do it I found online, and I can't get that to work either.
I'm following:
https://irfansworld.wordpress.com/2012/11/17/what-you-should-know-about-stored-procedure-universe-in-bi-4-0/
I created the objects shown in the exact same way, as shown here:
create or replace package emp_package
as type emp_row_type is ref cursor return emp%rowtype;
end emp_package;
/
create or replace
procedure getEmployeesByDepartment
(
return_rows_cursor in out emp_package.emp_row_type,
dept_parameter in emp.deptno%type
)
as begin
open return_rows_cursor for
SELECT *
FROM emp
WHERE emp.deptno = dept_parameter;
end;
/
I get good results back:
Package EMP_PACKAGE compiled
Procedure GETEMPLOYEESBYDEPARTMENT compiled
But here is where I see a glaring difference... For me, it takes what should only be the out/return parameters, and prompts me as if they are input parameters.
Even if i say "OK" to this... it doesn't recognize the fields in the "out" cursor as fields for me to show on the report.
I've even tried changing the cursor paramater from "in out" to just "out"... but still no luck.
Any ideas as to why I can't make this example work for me?
Using SAP Universal Design Tool 4.1.
Oracle 11g
This isn't really an answer, but too long for a comment.
I just tried this with BI4.1 SP Patch 5, and the SP Editor displayed as expected (only showing the DEPT_PARAMETER parameter).
Two possibilities I can think of for the different behavior you're seeing:
One is that there's something going on with the database middleware client that's confusing BO about the parameters. I'm using Oracle 11g client, and an Oracle Native connection in BO (i.e., not ODBC or JDBC). If you're using an ODBC or JDBC connection, try the native client instead.
It might be a bug with the specific version of UDT that you're using. I'd suggest upgrading, or contacting SAP support to see if it's a known issue.

ORA-06508: PL/SQL: could not find program unit being called : "PUBLIC.PLITBLM"

I have a java web app that calls the oracle plsql procedure from ibatis xml file. this procedure captures the audit information of the table. so when multiple users modifies a table this stored procedure .after certain time i receive the following error.
--- The error occurred in example.xml.
--- The error occurred while applying a parameter map.
--- Check the example.params.
Check the statement (update procedure failed).
Cause: java.sql.SQLException: ORA-04068: existing state of packages has been discarded
ORA-04065: not executed, altered or dropped stored procedure "PUBLIC.PLITBLM"
ORA-06508: PL/SQL: could not find program unit being called:
"PUBLIC.PLITBLM" ORA-06512: at "AUDIT", line 279
ORA-06512: at line 1
call from ibatis
{call AUDIT(?,?,?,?,?,?,'val')}
call from java web app
Map _temp = new HashMap(params);
_temp.put("OPERATION_TYPE",operation);
sqlMapper.insert("call_proc_audit",_temp);
return false;
The plsql procedure has only execute immediate for insert,update and delete.
I have removed the code due to security.
The PLITBLM package is part of the standard Oracle build; apparently it handles index organized tables. It's not documented in any detail because it's not something we need to call directly. Find out more. It's likely that some standard Oracle functionality has dependencies on it.
As to why your program hurls that exception, that's a bit of a facer. The package is created by a script in the Oracle home $ORACLE_HOME/rdbms/admin/plitblm.sql. However, it cannot be run on its own but only as part of catproc,sql. This builds the data dictionary and other things, and is run as part of the Oracle installation process.
Perhaps you have a botched install?
Interestingly, the actual PLITBLM package is owned by SYS but the error message references PUBLIC, which suggests it might just be a missing public synonym. However, if catproc,sql has not run successfully there may be other lurking nasties. You really need a DBA to check the database, and if necessary re-run catproc,sql.

Insert, delete ,update when using Stored Procedure component

We have an application written in Delphi 2010 which connects to SQL Server Database. Now we're in the process of migrating to Oracle. With SQL Server it was very easy to perform insert, update, delete right from a dbgrid connected to a Stored Procedure.
It's because stored procedures in SQL Server can easily act as a table so that you can do any operation on it, providing it returns the necessary columns within the resultset. Now with Oracle I don't know how do do it. I connect a DBGrid to a DataSource, dataset of which is a Stored Procedure object,but I can't edit the grid. Just Select is possible.
What do I have to do to to achieve this?I use UniDac component suite to connect to Oracle database.
Oracle does not support such functionality. IOW, in Oracle you cannot edit result set provided by a stored procedure or include stored procedure into INSERT INTO <name>, UPDATE <name> or DELETE FROM <name>.
While it is traditional for SQL Server developers to "always" use stored procedures (due to many reasons), it is not traditional for Oracle developers. But it is possible with Oracle too. Search for "REF CURSOR" to see how to fetch data using SP. And use normal or packaged (preferred) SP to post updates to a DB. These procedure will receive old / new field values through arguments.
I cannot say precisely about UniDAC, I can say about AnyDAC. But I will expect UniDAC has similar functionality. To use SP for posting updates you will need to use TXxxUpdateSQL component.
OK,here I'm answering the question though I can see very few are dealing with Delphi recently. Let's say we have a stored proc in Oracle database:
CREATE OR REPLACE PROCEDURE GET_EMPLOYEES
(V_CUR IN OUT SYS_REFCURSOR)
AS
BEGIN
OPEN V_CUR FOR SELECT * FROM EMPLOYEES;
END GET_EMPLOYEES;
Now, in Delphi you pick a stored procedure component (probably from ODAC or UniDac component suite).Set its StoredProcName GET_EMPLOYEES. Then you can add all the fields that the procedure returns in a cursor.If you run the application and activate the stored procedure you'll be able to see all the records. But if you try to insert, modify or delete anything you'll fail to do so. Now, there's a very tricky thing. If you check, you'll see that ReadOnly property of all fields are set to True. Even after you set them to False nothing will change in the real database, although you can edit the DBGrid.
So, we've come to the main part. How did the old Delphi-SQL Server partnership work so that you could do any operation right from a DBGrid? Well, we must understand that there's no magic. If it's SQL, then SQL has only one way of INSERTING,UPDATING and DELETING records-it's with the appropriate SQL statements.With Delphi-SQL Server there seems to be an implicit SQL statement that we never paid attention. But with Oracle, we have to provide our own statements for each operation.
If you use UniDac or ODAC then there's SQLInsert,SQLUpdate,SQLDelete properties in a StoredProc object.If you want to insert a record through DBGrid, then you should edit its SQLInsert property to
INSERT INTO EMPLOYEES VALUES(:EMPLOYEEID,:EMPLOYEENAME)
where variables following : are corresponding to te fields of the stored procedure.They're simply bind variales.When updating and deleting though you'll need some unique value to represent a specific record. Primary key is one option(maybe the only option as I haven't been able to figure out how to use ROWID for the same purpose).So the sql statements for UPDATE and DELETE would be
DELETE FROM EMPLOYEES WHERE EMPLOYEEID=:EMPLOYEEID
and
UPDATE EMPLOYEES SET EMPLOYEENAME=:EMPLOYEENAME WHERE EMPLOYEEID=:EMPLOYEEID
P.S. I just found a way to use ROWID for update and delete statements. In your stored procedure if you choose ROWID too and give it an alias then you can construct your UPDATE and DELETE Statements like such:
UPDATE EMPLOYEES SET EMPLOYEENAME=:EMPLOYEENAME,..... WHERE ROWID=:RECORD_ROWID
DELETE FROM EMPLOYEES WHERE ROWID=:RECORD_ROWID
In the preceding statements RECORD_ROWID is the fieldname returned from stored procedure as a result of aliasing ROWID. If you use :ROWID instead you'll get "ORA-01745: invalid host/bind variable name" error. This is because in a binding variable a colon cannot be followed by a reserved word. And ROWID is a reserved word.

to_char produces different outputs depending on where the procedure is called

We're using a stored procedure provided by a remote system. For testing purposes, I call this procedure from my development machine. Now the problem is if I call the procedure from Toad, everything is OK. But when I call it using SQL Developer an error happens.
I debugged and debugged and found out this: In the procedure, an expire date is generated and passed to a web service (don't ask me why).
Here are the lines responsible for generating the date:
vt_User.EXPDATE := TO_DATE('01.01.2025', 'dd.mm.yyyy');
vs_Value := to_char(vt_User.EXPDATE, 'YYYY-MM-DD"T"HH24:MI:SSTZR');
vs_Value, when called from Toad is generated like:
2025-01-01T00:00:00+02:00
But if I call from SQL Developer, it's like:
2025-01-01T00:00:00EUROPE/ATHENS
Everything except these lines are exactly the same. I tried many different approach, trying to set NLS_LANG, altering the session etc but to no result.
I need to solve this because the same thing happens when I call the procedure from Java code also and that's the main issue.
I connect to the remote database using TNS for Toad and SQL Developer, thin driver for the Java code.
In Oracle DB you basically have a TIME_ZONE definition for the DB, but you can change it for a session.
In this case the DB time_zone is set in the Absolute offset from UTC format which is what you want.
Probably the SQL Developer opened the session in Time zone region name format, as could be seen with:
select sessiontimezone, dbtimezone from dual;
So, altering the session to be as dbtimezone may help.
ALTER SESSION SET TIME_ZONE=dbtimezone;
have another solution using tzh and tzm:
select to_char(current_timestamp, 'yyyy-mm-dd"T"hh24:mi:sstzh:tzm') from dual

Resources