Call another schema in a cursor
Hello worldI am trying to export data using UTL_FILE and using a function that receives the SQL as a parameter. Thus, the opening of the cursor within the function like this:
OPEN C_Cursor FOR P_Query;
P_Query contains SQL code, and it works with tables on the same schemafor example.
P_Query = ‘select col1, col2 from table1’)
But when I set P_Query to select another schema, it fails.for example
P_Query = ‘select col1 from schema2.table1’;
I know that if I try this, will work:OPEN C_Cursor FOR 'SELECT col1 FROM '||schema2||'.table1';
But I need to set the schema of the function parameters.My question: is there a way to select another schema with a slider, just change the sql script?
Rafhael Dantas says:
But when I set P_Query to select another schema, it fails.
Well, when I open my wallet, I can see what is inside, but when I try to open the wallets of my colleague... :). In order to select from one table to the other schema, you must have the appropriate privileges. In addition, if the option is within the rights define object stored, privilege must be granted directly, without going through the role.
SY.
Tags: Database
Similar Questions
-
How to import with datapump tablespaces and another schema?
Hi, I need to import with datapump to another schema, data in 'x' tablespace and indexes in the tablespace 'y'
example:
My schema: prueba
I need to import the schema "prueba" but the data must be in the tablespace called "Tb1" and its index should be in the tablespace called "Tb2".
So, how can I do?
Any help will be appreciated.
As the noted the ground, do two imports, exclude to limit import and map objects to the appropriate storage space (to know what tablespace they were however)
import 1 - exclude = index remap_tablespace = source: tb1
import 2 - exclude = remap_tablespace = source table: tb2
-
Re: "insufficient privileges" error when you run the Java stored procedure in another schema
I get an "insufficient privileges" error when you run the Java stored procedure in another schema, see details below. I don't know what are missing privileges (I already granted the EXECUTE privilege), suggestions? -Thank you.
Define a simple java class and deploy it as a Java stored procedure to test:
Schema: User1
test of the package;
public class HelloWorld {}
public HelloWorld() {
Super();
}
public static String Hello () {}
Return "HELLO";
}
}
CREATE or REPLACE FUNCTION HELLO RETURN VARCHAR2 AUTHID CURRENT_USER AS LANGUAGE JAVA NAME ' test. HelloWorld.hello () return java.lang.String';
Grant execute on USER2 HELLO
Test the Java stored procedure through the PL/SQL function call (in the same schema):
Schema: User1
SET SERVEROUTPUT ON
DECLARE
v_Return VARCHAR2 (200);
BEGIN
v_Return: = User1. HELLO;
DBMS_OUTPUT. Put_line ('v_Return =' | v_Return);
END;
anonymous block filled
v_Return = HELLO
Test the Java stored procedure through the PL/SQL function call in a different pattern:
Schema: USER2
SET SERVEROUTPUT ON
DECLARE
v_Return VARCHAR2 (200);
BEGIN
v_Return: = User1. HELLO;
DBMS_OUTPUT. Put_line ('v_Return =' | v_Return);
END;
Error report-
ORA-01031: insufficient privileges
ORA-06512: at "User1." HELLO', line 1
ORA-06512: at line 4 level
01031 00000 - "insufficient privileges".
* Cause: An attempt was made to change the user name or password
without the privilege appropriate. This error also occurs if
trying to install a database without the need for employment
access privileges.
When Trusted Oracle is configure in DBMS MAC, this error may occur
If the user has been granted the privilege necessary for a higher label
that the connection is active.
* Action: Ask the database to perform the operation or grant administrator
the required privileges.
For users Trusted Oracle get this error, well that granted the
the privilege that is suitable for the top label, ask the database
administrator to grant the privilege to the appropriate label.
You have created the function with AUTHID CURRENT_USER, which means that the function is executed with the rights of the applicant (but not with the rights of the author). This means that the applicant must have grants (directly or through roles) on all used/accessible objects in the service. In your case the user USER2 has not granted with EXECUTE on the class/source Java test. Class HelloWorld, causing the ORA-01031 exception. You create service without AUTHID CURRENT_USER (i.e. with AUTHID DEFINE, which is by default, if you do not have a specific reason to use AUTHID CURRENT_USER) or grant EXECUTE on JAVA test SOURCE. Class HelloWorld to User2.
Dimitar
-
Access to the content of the tables of a schema into another schema
Hello
I have my doubts... Suppose I have a user called DEMO and it has tables. now I have another user called DEMO1
my doubt is. How can I get the DEMO user tables in DEMO1. If updating the table DEMO1 which should reflect
DEMO user. Help me...Dear friend,
You can consult the tables of a schema in another schema using the following steps.
(1) you must grant privileges on table demo Demo1, here's the statement to do so.
Grant Select, update on the table table_name to Demo1
(2) Create in Demo1 for the table_name demo, the suite is about education to do.
SYNONYM to CREATE or REPLACE table_name for Demo.table_name;
(3) do the Update statement on the table table_name in Demo1. Updated these results reflected in demo when you post the update statement in Demo1.
Hope that gives you an idea.
Kind regards
Ravi Kumar Ankarapu. -
access a type of user to another schema (collection)
Hello
In my scheme of production, I created a user type:
I use the TT_my_table collection as a parameter of a procedure type.CREATE TYPE T_my_row OID '4711' IS OBJECT(field1 varchar2(10), field2 number(10)); / CREATE TYPE TT_my_table OID '0815' IS TABLE OF T_my_row; /
Intended to test, I would like to call this procedure from another schema (SQL-developers UT repository). This is why I need 'access' to the collection type of this test pattern.
What are the rights I give to achieve?
Good bye
DPT
Edited by: T.PD the 29.06.2010 10:40Dear T.PD,
I think that under query will work for you;
SQL > GRANT EXECUTE, DEBUG ON TYPE_NAME TO SCHEMA_NAME.
It will be useful,
Ogan
-
call another proc and passing the values in the exception block
Hello
I'm trying to call the procedure another passing values in the exception block... but I couldn't m figure out how would the values in the exception block
Thank you very much!!create or replace procedure test_proc is cursor test_cur is select update_dt from test_tbl; test_rec test_cur%rowtype; begin for test_rec in test_cur loop begin insert into test_tbl values (test_rec.update_dt); commit; exception when others then rollback; -- test_proc2(update_dt) -- want to call another procedure and want to pass that update_dt here ; this process will insert the update_dt into the message table commit; end loop; end; My question is how do i pass value(update_dt) into the exception block or do i need to create any varaible ?? any idea
BTW, you can still use SQL % BULK_EXCEPTIONS even if you don't use EXCEPTION to LOG. You just can't use ORA-24381, since it will not be raised. Using SO many OTHER instead. And of course, there will be only one element in SQL % BULK_EXCEPTIONS:
SQL> CREATE TABLE emp_temp AS SELECT * FROM emp; Table created. SQL> DECLARE 2 TYPE empno_tab IS TABLE OF emp.empno%TYPE; 3 emp_sr empno_tab; 4 errors NUMBER; 5 dml_errors EXCEPTION; 6 PRAGMA EXCEPTION_INIT(dml_errors, -24381); 7 BEGIN 8 SELECT empno BULK COLLECT INTO emp_sr FROM emp_temp; 9 FORALL i IN emp_sr.FIRST..emp_sr.LAST --SAVE EXCEPTIONS 10 UPDATE emp_temp SET job = job || '_SR' 11 WHERE emp_sr(i) = emp_temp.empno; 12 EXCEPTION 13 WHEN OTHERS THEN -- Now we figure out what failed and why. 14 errors := SQL%BULK_EXCEPTIONS.COUNT; 15 DBMS_OUTPUT.PUT_LINE('Number of statements that failed: ' || errors); 16 FOR i IN 1..errors LOOP 17 DBMS_OUTPUT.PUT_LINE('Error #' || i || ' occurred during '|| 18 'iteration #' || SQL%BULK_EXCEPTIONS(i).ERROR_INDEX); 19 DBMS_OUTPUT.PUT_LINE('Error message is ' || 20 SQLERRM(-SQL%BULK_EXCEPTIONS(i).ERROR_CODE)); 21 END LOOP; 22 END; 23 / Number of statements that failed: 1 Error #1 occurred during iteration #2 Error message is ORA-12899: value too large for column "SCOTT"."EMP_TEMP"."JOB" (actual: 11, maximum: 9) PL/SQL procedure successfully completed. SQL> DROP TABLE emp_temp; Table dropped. SQL>
SY.
-
With the help of the TYPE operator % on objects in another schema
Suppose I have the following architecture:
* A schema called APP_SCHEMA (for example), which contains all applications level PL/SQL packages that contain a business application logic
* A data schema, called DATA_SCHEMA (for example), that contains the schema objects that are referenced by the PL/SQL in APP_SCHEMA
Suppose I create a simple procedure like this in the APP_SCHEMA:CREATE OR REPLACE PROCEDURE test_proc(pVar IN DATA_SCHEMA.TABLENAME.TABLECOLUMN%TYPE) AS BEGIN DBMS_OUTPUT.PUT_LINE(pVar); END; /{code} For this simplified procedure I get the following error: {code:java}1/25 PLS-00201: identifier 'DATA_SCHEMA.TABLENAME' must be declared{code}So, my basic question is how do I use the %TYPE operator to reference objects in another schema? Other Pertinent info: * Windows Server 2003 * Oracle Database 10gR2 (10.2.0.3) Thanks!
Its almost certainly a problem of privileges.
I can create a test procedure based on the same script that compiles successfully.
Verify that your user can access the table. Might need to have to grant access directly, rather than in a role.
Published by: Keith Jamieson on August 25, 2008 17:51
typo fixed -
When calling another country gives the time in this country?
When calling another country, Skype tell you the time in the country you call?
Hello and welcome to the Skype community.
N ° as currently configured the system does not support this facility.
TIME ZONE - US EAST. LOCATION - PHILADELPHIA, PA, USA.
I recommend that you always run the latest version of Skype: Windows & Mac
If my advice helped to solve your problem, please mark it as a solution to help others.
Please note that I usually do not respond to unsolicited private Messages. Thank you. -
Import a table from a fullexport to an another schema with a different name
Hello
I habe a full export created with expdp. I want to import a table (tkz.verlauf) of this fullexport to another schema (Tom) with another (zzz) name of this table.
I tried this:
content = all
Full = N
Directory = ORADUMP
dumpfile = fullexp.dmp
sqlFile = IMP. SQL
logfile = IMP.log
schemas = tkz
tables = verlauf
remap_schema = tkz:blubb
REMAP_TABLESPACE = verlauf:zzz
But it does not work:
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle 12 c database Release 12.1.0.1.0 - 64 bit Production
UDI-00010: several work modes, patterns and paintings.
When I use it without the 'paintings' all tables will be imported.
Can someone help me?
Best wishes Jessica
Hi Jessica,.
You must just have something like this
Directory = ORADUMP
dumpfile = fullexp.dmp
logfile = IMP.log
tables is TKZ. Verlauf
remap_schema = tkz:blubb
remap_table = verlauf:zzz
Not sure if you want to rename the table or put a different tablespace (I did rename the table) - replace the last line with rather than table tablespace if you just want it in a different tablespace.
See you soon,.
Rich
-
Insufficient privileges in the creation of MV that he select another schema table
Hello
Before asking this question, I checked with similar questions in the forum, but I don't see my situation, or I'd say I'm not clear on the solution.
I got the privileges CREATE MATERIALIZED VIEW and CREATE ANY MATERIALIZED VIEW and I want to create a MV in my schema, but the MV selects data in another schema, and I had the privilege to choose this table. Here is my code
Create VIEW MATERIALISEE CPY_GL_HANDS_OFF_DTL
UPDATE THE BEGINNING WITH THE LARGEST (SYSDATE, TO_DATE ('2013.10.30.23.30.00 ',' YYYY.)) MM DD. HH24.MI. THE NEXT SS SYSDATE')) + (50519 /(24*60*60)) FULL
ENABLES QUERY REWRITE
SELECT
*
Of
User_a.GL_HANDS_OFF_DTL@dblink;
I run it, and I get ORA-01031: insufficient privileges. According to my research so far, the schema of the latter requires the CREATE TABLE privilege, even though she already had RESOURCES (which already includes the CREATE TABLE). Is this true? That's my problem. I only have read access to the table of the dblink, I can't control the privileges of this scheme. Advise please if this is the real problem?
Thanks and greetings
acquired through ROLE privileges do NOT apply in the PL/SQL name procedures
-
Drop database link in another scheme that DBA is not working
How to remove an object for example, database 'MYDB. MYDBLINK"that is present in the SCOTT schema.
When I try the following options of logged in as DBA , it is in error.
"DROP DATABASE LINK"SCOTT" MYDB. MYDBLINK1 ';
ORA-2024: connection to database not found.
DROP DATABASE LINK SCOTT. MYDB. MYDBLINK1;
ORA-2024: connection to database not found.
DROP DATABASE LINK 'SCOTT'.' MYDB. MYDBLINK1';
ORA-2024: connection to database not found.
DROP DATABASE LINK SCOTT. MYDB. MYDBLINK1;
ORA-2024: connection to database not found.
I always connect like SCOTT to drop the MYDB database link. MYDBLINK1 that is present in the SCOTT schema.
Please provide the way to drop the database link in another schema, without logging as the schema owner, so that I can connect a DBA (SYSTEM or SYS).You cannot remove a database link in the schema of another user. One solution is:
SQL > CREATE PROCEDURE scott.drop_db_link AS
BEGIN
EXECUTE IMMEDIATE 'drop database link LINK1. "
END drop_db_link; 2 3 4
7 mCreated procedure.
SQL > exec scott.drop_db_link
PL/SQL procedure successfully completed.
Source: http://dbaoracletips.blogspot.com/2011/11/how-to-dropcreate-database-link-from.html
http://laurentschneider.com/wordpress/2012/10/drop-database-link-in-another-schema.html -
How to share data in the tables ' User_ * ' with another schema
I want to share the data in the table WHERE USER_SEGMENTS with another schema. If I create a view and grant select on the view, when the other schema queries the view data are identical to themselves querying the SYS.user_segments table directly.
My guess is that the SYS.user_segments table is a view based on the current user.create view sys_user_segments as select * from sys.user_segments; grant select on sys_user_segments to A;
Is there a way to share such data without creating a copy of the table?
Oracle: 10g
Thank youIf the ADMINISTRATOR is concerned about B access to DBA_SEGMENTS (or by creating DBA_SEGMENTS views that belongs to a user who has access on top and then grant access to this view of B), it seems pretty crazy allow that kind of database connection.
If you create a database link belonged to B that connects to A, B is, in substance, given any privilege that has exercises. But it is done in a very, very dark which will no doubt be neglected in the future when someone gets a check. He'll be sitting here to wait that someone (accidentally or intentionally) Decides to exploit the security hole and do something that is causing a problem (by removing all data from a table, grabbing all the sensitive data in a table, etc.). Risks of this almost certainly far, far* far * outweigh the risks of even leaving B to obtain direct access to DBA_SEGMENTS.
Justin
-
In Captivate 7, how can I call another action in action?
I have a conditional action called FakeSuccessRewind. Now I need to call another function, called ShowGrayBalloons02 of in the Else statement, but I couldn't find something like "Execute Action Advanced." Can someone share some advice here? Thank you!
Here are the screenshots of my two actions:
(1) FakeSuccessRewind (if/else). Here, I need to call the action 2 of the Else statement, under instruction to go to the next slide.
(2) ShowGrayBalloons02. Note that this feature has five separate tracks when the variable is decrement of 5-1.
Thank you very much!
Melissa
You can not, you add another action first.
-
grant the select privilege on the table in another schema by role error
Hello
I have a problem with the granting of privileges to another schema
I have A user who has only 1 system priv: connect, which has a private: create session;
I created a role X, which I have the privilege: select on a table to a diagram B customer.
I then conceded this X role to A user.
I can't select * B.customers when im connected to A
identification of information like it that I'm missing?
Thank you
Rgds>
but whenever I put a default role, the other is automatically set to zero-defectsHow did you receive the two default roles?
>
By running the code I posted above as user SYS.Drop your user and start again and use the code I posted.
-
Avoid calling the procedure in the cursor loop
Hi all
The following example of procedure the procedure written in cursor loop, is called each time until the end of the cursor loop...
What would be the alternative methods to write the procedure above instead to call the procedure inside the cursor for loopprocedure proc_main is DECLARE cursor c1 is select e.empno empno ,e.ename ename ,d.dname dname ,d.loc loc from emp e,dept d where e.deptno = d.deptno ; BEGIN for i in c1 LOOP proc_test(i.empno,i.ename,i.dname,i.loc) ; end loop; END; ----------- PROCEDURE proc_test (p_empno,p_ename,p_dname,p_loc) is --- --- begin select * into v1,v2,v3 .. from temp_tab where col1 =p_empno ---- ---- end;
My idea is to use collections... could you give me the code example using collections to meet the above criteria
Thank you
Published by: smile on February 28, 2012 15:45The ideal would be to collect all SQL logic and put as much of it in a single SQL statement as possible. It would be also great to determine what is the final outcome of the process and use it as a starting point for your SQL. For example, if the desired result is to upgrade the salaries of the employees where they have an entry in table x, you might find that you can avoid needing to separate the logic between multiple, i.e. instead of procedures
procedure proc_main is DECLARE cursor c1 is select e.empno empno ,e.ename ename ,d.dname dname ,d.loc loc from emp e,dept d where e.deptno = d.deptno ; BEGIN for i in c1 LOOP proc_test(i.empno,i.ename,i.dname,i.loc) ; end loop; END; ----------- PROCEDURE proc_test (p_empno,p_ename,p_dname,p_loc) is --- --- begin select * into v1,v2,v3 .. from temp_tab where col1 =p_empno ---- ---- UPDATE emp e SET sal = v2 WHERE e.empno = p_Empno; end;
You may simply have
procedure proc_main is BEGIN UPDATE emp e SET sal = ( SELECT t.new_sal FROM temp_tab t WHERE t.empno = e.empno ) WHERE EXISTS ( SELECT NULL FROM temp_tab t WHERE t.empno = e.empno ); END;
Even if your logic is more complex, you are likely to find that you can merge several of the statements that you could be running in a loop and replace that loop with a join.
Given the particular structure of what you posted if, instead of calling the procedure in a loop, you can simply move the cursor c1 as a parameter to proc_test that is
procedure proc_main is lc_c1 sys_refcursor; BEGIN OPEN lc_c1 FOR select e.empno empno ,e.ename ename ,d.dname dname ,d.loc loc from emp e,dept d where e.deptno = d.deptno ; proc_test(c1) ; END; ----------- PROCEDURE proc_test (p_Cursor sys_refcursor) is begin LOOP FETCH .... ...DO SOMETHING... EXIT WHEN p_Cursor%NOTFOUND; END LOOP; CLOSE p_Cursor; END;
But I highly recommend that you consider trying to merge as much of your SQL before considering the approach of cursor.
HTH
David
Maybe you are looking for
-
How do itunes run on windows Vista?
I used to run Itunes on my windows Vista computer. Recently, my computer crashed. I did a clean reinstall of windows Vista and downloaded Itunes again after that. Before installing, I saw that I would get a version for XP and Vista, so it should be t
-
volume licensing service in Windows Server
Can I add windows server to the list of the products that I use in the volume licensing service. Or how to add it in there is
-
Other download links for Microsoft Safety Scanner?
I tried to download Microsoft Safety Scanner http://www.microsoft.com/security/scanner/en-us/default.aspx for more than a dozen times now, but still it is interrupted. I have more virus in my computer, it's just that I think that my Internet connecti
-
I have bsod problems. I'm putting SFC and @ 57%, it stops and it displays a message that it couldn't perform... When activated the journal CBS found that it always stop here: 2010-07-09 18:08:19, CSI 000000ec c0000185 (F) error [error, installation =
-
Screen flickers at the office & hole back Outlook email
Hi, we just bought a Netbook from Toshiba NB200 with 1 GB of ram and a 1.6 GHz processor Atom. She has Windows Home Premium installed. About passing to preview full view of emails (and also sometimes changing calendar to email & return) the screen fl