Oracle synonym for remote package / procedure - oracle

we have a package/procedure in a remote database. Say PACKAGE_1.PROCEDURE_1. We want to create a synonym in the local database, that will allow us to still call the package.procedure without coding a DB link in the call. So, to the caller, it looks as though the package.procedure is local to that database.
Can this be done using a synonym?

Sure, you'd just create the synonym
create [public] synonym package_name
for schema_name.package_name#db_link;
Then you'd just call
package_name.procedure_name
in your code and wouldn't need to reference the database link.

Related

Call procedure from different schema which has ACL privilege but caller doesn't

One schema in our database has ACL privilege to an URL and can send requests to this URL. If I now write a procedure in this schema that sends the request and grants a different schema the option to execute this procedure, will it work or does the second schema also need the ACL privilege?
I am asking to plan the necessary approach to this topic since I need to write an package in the second schema.
If I understood it correctly it seems like that by default the authid property is set to definer rights. This should mean that it executes with the privileges of the owner of the schema.
And it indeed did!
Refrence:
https://docs.oracle.com/database/121/DBSEG/dr_ir.htm#DBSEG658
https://docs.oracle.com/cd/B28359_01/appdev.111/b28370/create_package.htm#LNPLS01371
https://docs.oracle.com/cd/B28359_01/appdev.111/b28370/subprograms.htm#LNPLS00809

Oracle - Export DDL and Data from Schema in correct order

I need to create a copy of DDL and Data from an Oracle 12cR1 schema.
I can't use the SYS or other High Privileges user.
I can only use SQL DEVELOPER using the schema credentials.
The rights I have are:
Create and alter object privileges within the schema (such as CREATE
TABLE).
Insert, read, update and delete data privileges on the tables
within the schema.
Execute privileges on the stored procedures,
functions and packages within the schema.
I can use Oracle SQL Developer or other third party tool.
I have used the "Database Export" functions, but I ahve found no way to get both the DDL and the INSERT queries in the correct order. Some table have dependencies, so I need to respect a logic order for both DDL and Queries.
In my opinion, you should use a tool which is designed to do such a task, and that's Data Pump (Export & Import). It requires you to acquire privileges on a directory which resides on the database server, and that's something that a privileged (SYS) user creates and grants. If there's a DBA there, ask them to provide it for you.
If there's none, you can still use the Original EXP utility which creates a DMP file on your own computer.
The advantage of the export is that Oracle handles everything that seems to bother you.
If I were you, I wouldn't do it manually, there's really no need to do it that way. Apart from the fact that it is time-consuming, you'll have to take care about foreign key constraints, create slow INSERT INTO statements ... shortly, don't do it. Use (Data Pump) export and import.
You can disable all the constraints and triggers first, then insert the data. After data loaded, enable them all.
You can also try to use PL/SQL Developer to export the objects first. This tool exports objects in dependency order. Then export the data, but not sure it exports the data in dependency, you can try if there are disable constraints/triggers option when export.

Oracle SQL Developer package and package body copy and compile from one schema to another

I have several Oracle schemas including the same PL/SQL packages and package bodies.
If I make changes in one package in one schema, what is the best way to move these same changes to all other schemas as well ?
I can copy the PL/SQL code from one schema and then paste it to another schema and compile there, but if this has to be done tens of times it doesn't seem appropriate to me.
Don't have multiple copies of the same code.
Use:
GRANT EXECUTE ON USER_NAME.PACKAGE_NAME TO OTHER_USER;
To allow one user to own the code but allow other users to execute it.
If you need to run procedures as the calling user then set the invoker's rights to AUTHID CURRENT_USER rather than the default of AUTHID DEFINER in the procedures within the package.
Then you only need to maintain a single copy of the package.

Is pl/sql don't use sql*plus command in Oracle?

example:
create or replace procedure DEMO is
begin
--host dir
--execute immediate 'host dir';
end DEMO;
I pupose invoke window's procedure in Oracle.
I try to use #command in sql*plus, but it discontent my requirement.
Stored procedures run on the database server. SQL*Plus commands are executed on the client. You cannot, therefore, use SQL*Plus commands in a stored procedure.
There is no way realistically for a stored procedure to get a directory listing for a directory on the client machine. (You could, I suppose, have the client expose a shared directory and mount that from the server and the read the contents from the database but that isn't something that would be realistic in the vast, vast majority of cases). A stored procedure can potentially call out to the database server's operating system using a Java or CLR stored procedure or, depending on the version, using the dbms_scheduler package. But there are a lot of security issues to be concerned about before implementing something like this.

Oracle :: Calling Packaged Stored Procedures

In my Project i have stored procedure in package i like to call it directly in my project like HRPKG.ADD_JOB_HISTORY it retuen Stored procedure is not defined but if i called it like from UserName like HR.HRPKG.ADD_JOB_HISTORY it called successfully
Note : I Connect wit oracle using ODBC In Message Broker !
You cannot refer your SP directly without any username.You need your username/schema name for reference.If you dont use any User then how will it know where to take the SP from.Its the syntax.
HR.HRPKG.ADD_JOB_HISTORY
HR-uname
HRPKG-package
ADD_JOB_HISTORY-SP
It goes like find the SP ADD_JOB_HISTORY under the package HRPKG in HR schema

Resources