Stored Procedure executes on two different schemas in Oracle 8i
Can I Create a Stored Procedure that access table from two different schemas?
For Example I have created this Stored Procedure on SCHEMA_ONE
CREATE OR REPLACE PROCEDURE SP_DEMO IS
BEGIN
INSERT INTO SCHEMA_ONE.COUNTRY_ONE(COUNTRY_NAME)
SELECT COUNTRY_NAME
FROM SCHEMA_TWO.COUNTRY_TWO
END SP_DEMO;
and when I execute it I am getting error message as :
Error: PLS-00201: identifier 'SCHEMA_TWO.COUNTRY_TWO' must be declared
is that possible? If yes then what I need to do for that?
Please assist me.
hi john
How are you?
please have a view there and correct me if m wrong.
insufficient privileges
Khurram Siddiqui
[email protected]
Similar Messages
-
Joining two tables in two different schema
Hi All,
I have a requirement to join two tables in two different schema. How to join these two tables in view object.
Many thanks in advance.
Regards
Kaushik Gopalakrishnan1) If these tables are in one and same database instance, then you can join them by specifying the fully-qualified table names (inlcuding the schema name), for example:
SELECT ...
FROM schema_A.table1 T1, schema_B.table2 T2
WHERE T2.parent_code = T1.code
AND ...2) If the tables are in different database instances, then you can create a database link in one of the databases and access the table from the other database via the DB link, for example:
SELECT ...
FROM schema_A.table1 T1, schema_B.table2@mydblink T2
WHERE T2.parent_code = T1.code
AND ...3) If the tables are in different database instances and there is no option for DB links, then you cannot join the tables in an ADF ViewObject.
Dimitar -
Query Timeout on stored procedure executed from Access 2010
I am trying to delete old jobs from a SQL 2008 R2 database. I created a stored procedure on the server that deletes all Jobs over 1 year old. The delete can take several minutes to run as it deletes record on several related tables. I am getting a error
"2147217871 - [Microsoft][ODBC SQL Server Driver]Query timeout expired". The query runs fine on the Server. I have tried setting Client timeout to 300 sec but it times out way before 5 min. I am not sure what else I
can do to fix this problem. I am hoping someone has seen this and figured out a fix.
Here is there code
Public Sub Cleanup_Database()
On Error GoTo CleanUp_Err
Dim cmd As ADODB.Command
Set cmd = New ADODB.Command
ODBC_conn = "ODBC;Description=testbox2;DRIVER=SQL Server;" & _
"SERVER=O2GMSAPPTEST\SQL122DEVL;Trusted_Connection=Yes;" & _
"APP=Microsoft Office 2010;DATABASE=IMB_TraceData;StatsLog_On=Yes"
cmd.ActiveConnection = ODBC_conn
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "DataBase_Cleanup"
cmd.Execute
CleanUp_Err:
Dim i As Long
Dim str As String
str = ""
For i = 0 To Errors.Count - 1
str = str & Errors(i).Number & "-" & Errors(i).Description & " " & vbNewLine
Next i
If str = "" Then
str = Err.Number & " - " & Err.Description
End If
MsgBox str, , "Trace Update"
End Sub
You didn't say how you were setting the client timeout, but this has worked for me in an adp.
'Temporarily increase query timeout, which is an application-wide setting
'CurrentProject.Connection.CommandTimeout = 60 'Too late to change this setting- no effect
Const cstrTimeoutOptionName As String = "OLE/DDE Timeout (Sec)"
Const clngTimeoutSecondsForQuery As Long = 300
strQueryTimeOutOriginal = Application.GetOption(OptionName:=cstrTimeoutOptionName)
Application.SetOption cstrTimeoutOptionName, CStr(clngTimeoutSecondsForQuery)
Paul -
Transfer a binary file stored in a table field in oracle to another table different schema in oracle
I would like to know if it is possible to use ssis to transfer a binary file of a datatype of long raw in a field in one table in oracle to a new table in a different schema of a datatype blob in oracle? The binary file is a Crystal reports executable
which is used in a application that I support. I are trying to consolidate data fields over many schemas into one main schema to simplify the support issues.Hi r_peterser,
SQL Server Integration Services maps DT_IMAGE data type to LONG RAW and BLOB in Oracle. So, you can directly use an OLE DB Source or Oracle Source adapter to extract the LONG RAW column from the Oracle database, and then load the data to the BLOB column
of the Oracle table through an OLE DB Destination or Oracle Destination adapter.
Reference:
http://technet.microsoft.com/en-us/library/ms141036.aspx
Regards,
Mike Yin
If you have any feedback on our support, please click
here
Mike Yin
TechNet Community Support -
Create stored procedure with table from another schema throws PLS-00201
Oracle 10g. I'm new to procedures, so maybe I'm missing something obvious.
Schema owner ABC has table T2001_WRITEOFF. The SYSDBAs granted SIUD to Some_Update_Role, and granted that role to developer user IJK. User IJK then created a private synonym T2001_WRITEOFF for ABC.T2001_WRITEOFF. This worked with normal SQL DML commands.
When I try to create a simple procedure as follows, it throws PLS-00201 identifier 'T2001_WRITEOFF' must be declared, and points to the 2nd line.
create or replace procedure woof1(
fooname in T2001_WRITEOFF.territory%TYPE, <=== error points here
bardesc IN T2001_WRITEOFF.ind_batch_submit%TYPE) IS
BEGIN
INSERT into T2001_WRITEOFF
VALUES ( fooname, bardesc);
END woof1;
What am I doing wrong?
Thanks
JimRHi,
The reason I've heard has to do with knowing when a procedure becomes invalid due to privileges being revoked. Any time a grant to a role is revoked, you would have to check all procedures that depended on that role to know if they were still valid. Even worse, since roles can be granted to other roles, every time a role is revoked from another role, you would have to check all procedures that depended on anything to see if they were still valid.
Oracle 11 behaves the same as earlier versions in this regard, and I don't expect this to change.
This whole thread applies only to AUTHID DEFINER stored procedures (which is the default). If you can make the procedure AUTHID CURRENT_USER, then you can run it with privileges granted through roles. Usually, however, you really want AUTHID DEFINER, and granting the necessary privileges directly to the procedure owner (or to PUBLIC) isn't too hard. -
Usage of Varray in a Stored Procedure Executed through OCIStmtExecute
Hi,
I'm new to OCI Programming. My requirement is to pass an array to a Stored Procedure.
In Stored Procedure this input variable is of type VARRAY.
I'm following the approach given below.
OCITypeByName()
OCIObjectNew()
OCICollAppend()
OCIBindByPos()
OCIBindByObject()
OCIStmtExecute()
I encounter an error in OCITypeByName (this function call fails)
Can anyone provide me some sample codes
Also pls provide information if there is a better approach to be followed in this regard.
Thanks,
Alamelu
nullHi Alamelu,
Make sure you created the type correctly in the database using SQL DDL.
You can verify that from sqlplus
sqlplus username/password
describe typename;
Here is a code snippet :-
#define SCHEMA "TKP8ADT1"
OCITypeByName(envhpx, errhp, svchpx, (const text *) SCHEMA,
(ub4) strlen((char *)SCHEMA), (const text *) "ADDRESS_VALUE",
(ub4) strlen((char *)"ADDRESS_VALUE"), (CONST text *) 0,
(ub4) 0, OCI_DURATION_SESSION, OCI_TYPEGET_HEADER, &addr_tdo);
thanks,
Ravi -
Stored Procedures - Executing a query with multiple variables
Hello everyone..
During development I faced the followng problem. When I tried to execute a query in a stored procedure using 2 or more variables an unexplained error came up! The fact is that I use a form that calls this particular stored procedure using 2 variables.
Does anybody know why is this happenning?
Thanx!To better help you, could you provide the procedure (or part of it) and the query causing the error?
Hello everyone..
During development I faced the followng problem. When I tried to execute a query in a stored procedure using 2 or more variables an unexplained error came up! The fact is that I use a form that calls this particular stored procedure using 2 variables.
Does anybody know why is this happenning?
Thanx! -
How to get tab delimited text file when Stored Procedure executes ?
Hello Everyone,
I have a stored procedure which returns 1 result set as an output.
I want the output as a Tab Delimited Text file.
I know that I can use SSIS and get the same output but I am not allowed to use SSIS in this case.
Is there any other ways ?
I will be really appreciate If someone can answer with, How many different ways I can get Tab delimited text file ?
Thanks in advance
Henaryyou can do that by using SQLCMD
http://blog.sqlauthority.com/2013/03/05/sql-server-exporting-query-results-to-csv-using-sqlcmd/
you can also use BCP
EXEC master..xp_cmdshell 'bcp "select * from tempdb.dbo.orders" queryout "c:\output.txt" -c -T'
EXEC master..xp_cmdshell 'bcp "exec usertest.dbo.proctest" queryout "c:\output.txt" -c -T'
--Prashanth -
Stored Procedure to compare two tables data
Hello,
I want to have a Stored Procedure which will compare data (only a single column) of two tables and delete the row which is not present in the second table.
For eg.,
I have got 2 tables called Table1 and Table2, which have the same column called ID(PK).
The data in Table1 is 1,2,3 and data in Table2 is 1,3. When the stored procedure runs, it has to compare the ID column in Table1 to ID column in Table2 and since '2' is not there in Table2, I want to delete this row from Table1.
Thanks in advance.user11281601 wrote:
Hello,
I want to have a Stored Procedure which will compare data (only a single column) of two tables and delete the row which is not present in the second table.
For eg.,
I have got 2 tables called Table1 and Table2, which have the same column called ID(PK).
The data in Table1 is 1,2,3 and data in Table2 is 1,3. When the stored procedure runs, it has to compare the ID column in Table1 to ID column in Table2 and since '2' is not there in Table2, I want to delete this row from Table1.
Thanks in advance.
delete from table1 where id_column in
(select id_column from table1
minus
select id_column from table2); -
Read tables from different schemas in oracle
Hi, I'm trying to write a code to run a query to get data from an Oracle server, the problem is that the query refers to multiple tables in multiple schemas... the regular way to do it in oracle (SCHEMANAME.TABLENAME) does not work in excel vba query and
I cant find a way to so, any help will be really appreciated, below a sample code with one table from WWPP schema.....
Const DB As String = "Driver={Microsoft ODBC for Oracle};" & _
"CONNECTSTRING=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=1526))(CONNECT_DATA=(SERVICE_NAME=MyName)));" & _
"Uid=MyID;Pwd=MyPwd*;"
Sub test()
Dim cnt As ADODB.Connection, rst As ADODB.Recordset
Set cnt = New ADODB.Connection
Set rst = New ADODB.Recordset
cnt.Open DB
(I also tried this but didn't work) -> cnt.Execute "ALTER SESSION SET CURRENT_SCHEMA=WWPP"
rst.Open "SELECT * FROM WWPP.SO_LIFE_CYCLE_BACKLOG_RP", cnt, adOpenDynamic, 2
If rst.EOF = False Then
Sheet1.Cells(2, 2).Select
Selection.CopyFromRecordset rst
End If
rst.Close
End Sub
Oscar Marquez1) Posting the error number (i.e. ORA-00942) in addition to the error message is often quite helpful since that's generally far easier to look up and far less likely to get confused in translation.
2) Are you using an invoker's rights stored procedure? Or a definer's rights stored procedure? If you're not sure, the default is definer's rights.
3) How has YFS been granted access to the Y_PS table? My hunch is that it was granted access via a role, not via a direct grant. Privileges granted through a role would be available for ad hoc SQL queries, but those privileges are not available to a definer's rights stored procedure. A definer's rights stored procedure only has access to the privileges granted directly to the owner.
If my hunch is correct, you'd either have to directly grant YFS access to the table(s) it needs to access in other schemas or you'd need to make the stored procedure use invoker's rights, which may have ripple effects down the line if users other than YFS are going to be running the procedure.
Justin -
Oracle: PL/SQL Procedure involving two different Schema in two different Databases
I got a scenario like this, I have an existing procedure that looks similar to this.
PROCEDURE A_DATA_B( p_ID IN SCHEMA1.TABLE1.ID%TYPE,
p_MATCH IN SCHEMA1.TABLE2.MATCH%TYPE,
p_STATUS IN SCHEMA1.TABLE3.STATUS%TYPE,
p_MSG IN SCHEMA1.TABLE1.MSG%TYPE,
The list goes on...
The SCHEMA1 was residing in the same database previously. Now this needs to be moved to another database in different server as such. But the schema name goes to be different but the Table name and the column name remain the same. So I changed the procedure to look like this
PROCEDURE A_DATA_B( p_ID IN SCHEMA2.TABLE1.ID%TYPE,
p_MATCH IN SCHEMA2.TABLE2.MATCH%TYPE,
p_STATUS IN SCHEMA2.TABLE3.STATUS%TYPE,
p_MSG IN SCHEMA2.TABLE1.MSG%TYPE,
The list goes on..
But when I compile I got the error
PLS-00201: identifier 'SCHEMA2.TABLE1' must be declared
PL/SQL: Declaration ignored
I can understand from this error that SCHEMA2 is not in the database which gives the error. So How should I tackle it?
In the package body where ever am using this SCHEMA2 has been followed by an @db_link. So can I make use of that db_link to solve this?
By looking in to some article I came to know that SYNONYM can also be used. So is this the right way to create a synonym will work?
CREATE SYNONYM SCHEMA2 FOR SCHEMA2@db_link;
Can Someone help me in this regards.
Notes : I may not be able to convert the %type to varchar2 or numbers etc..
Thanks In Advance.This works for me:
PROCEDURE A_DATA_B( p_ID IN SCHEMA2.TABLE1.ID@dblink%TYPE,
p_MATCH IN SCHEMA2.TABLE2.MATCH@dblink%TYPE,
p_STATUS IN SCHEMA2.TABLE3.STATUS@dblink%TYPE,
p_MSG IN SCHEMA2.TABLE1.MSG@dblink%TYPE,
Alternatively create a synonym for the table (you can't create a synonym for a schema):
create synonym ref_table1 for SCHEMA2.TABLE1.ID@dblink
PROCEDURE A_DATA_B( p_ID IN REF_TABLE1.ID%TYPE,
p_MATCH IN REF_TABLE2.MATCH%TYPE,
p_STATUS IN REF_TABLE3.STATUS%TYPE,
p_MSG IN REF_TABLE1.MSG%TYPE,
but I don't like the idea of depending on a schema in another instance at all.
Can you create a reference set of tables in a schema on the current database, to be the source for the data types? -
How to get a rowcount from two different schema in two different databases?
Hello,
I want to count of rows in each table in a schema say test, of DEV1 database to another schema say test of DEV2 database. both have same schema data in both the databases. my output should look something like this.
Tablename
database name DEV!, schema name test , tablename: count
database name DEV2, schema name test , tablename: count
can someone help me please.
Thanks a lotGive this a try in dba1 - assuming there is a db link in dba1 to dba2:
select 'DBA1', count(*) from table
union all
select 'DBA2', count(*) from table@dba2
Note that if these are large tables, you may want to gather stats on the two tables (IMPORTANT) and then do
select 'DBA1', num_rows from all_tables where table_name = 'TABLE'
union all
select 'DBA2', num_rows from all_tables@dba2 where table_name = 'TABLE'
If you don't gather stats - the num_rows column in all_tables will reflect the number of rows that were present when stats were last gathered and will not reflect any inserts/deletes that have taken place since.
The "union all" clause differs from "union" in that "union all" shows every matching result from both halves of the union - whereas union will only show each unique result once.
Hope this helps! -
What happens when a Stored procedure shared by two jobs and get called at same time ?
Hi All,
Not sure its the right way to do it , I wrote a MASTER SP which calls three different SP using variables passed to MASTER SP.
MASTER SP calls the three SP using EXECUTE IMMEDIATE COMMAND, My question imagine two jobs (Job1) and (Job2) running same time and calling MASTER SP but passing different varaibles what happens here does Job2 wait for Job1 to complete or does SQL Server
or any database engine clever enough to create two copies of MASTER SP to exeucte the varaibles passed by Job1 and Job2 so it can run in parallel.
Thanks
sri
Sri.TummalaIts Oracle so you need to post it in Oracle forums like
https://community.oracle.com/community/database/oracle-database-options/sql_and_pl_sql
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
Can we send a message to Websphere from two different schema?
Hi,
I have two schema in my test environment and i send a AQ message to WebSphere from one of them.
Now i'm going to apply all the changes from this schema to the other one and then two messages will go to the same destination in IBM WebSphere!
Do you think i might face a problem in this way or i should disable the previous one?
Regards
/HesiHello,
it surely depends on your setup logic for the content of your target MQ messages. From the point of AQ there is no problem.
Your two AQ queues don't know anything from each other. You have to check if the messages can be arrive twice at
your destination MQ queue.
Kind regards,
WoG -
Find the difference in Two Tabels in two different schema?
Hello Gurus,
In DB which have millions of records -
I have a Tabel A under Schema A and i have another Tabel B under Schema B and i have to pick the refrence from Tabel C under Schedma B altough my DB is same. Both of the tables (Table A and Table B) have exatly the same structure in both the schema and when i tried finding the difference like -
Find the refrence from Table C and pick the values which are in Tabel A under Schema A but which are not present in the Tabel B under Schema B .
I have to compare each and ever field value which is present under all of the columns under Table A to ever field value which is present under all of the columns under Table B.
then wrote the following query-
SELECT * FROM
SchemaA.Table A t1,SchemaB.Table C t2
WHERE t1.SV_ID = t2.SV_ID order by t1.SV_ID
Minus
Select * from SchemaB.TableB order by SV_ID
Then this query is not working. And display the following error -
"query block has incorrect number of result columns"
Even both of the tables have the same column's and same structure.
Kindly help me .
Looking forward for some guidance -
Thanks in advance.1-There are some 70 Columns in both of the tables so thats why i don't want to use the query based on columns as it will involve writing all of the columns.
2- By using the query something like -
select <column_name(s)> from table1
minus
select <column_name(s)> from table2, table1
where <condition>
It is throwing the error -ORA-01789: query block has incorrect number of result columns
3- Using the query
SELECT t1.*
FROM SchemaA.TableA t1,SchemaB.TableC t2
WHERE t1.SV_ID = t2.SV_ID
MINUS
SELECT t3.*
FROM SchemaB.TableB t3
order by SV_ID
It gives me the reuslt but when i corss check them individually in both of the tables then there is no difference.
4- SELECT t1.* FROM
SchemaA.Table A t1,SchemaB.Table C t2
WHERE t1.SV_ID = t2.SV_ID order by t1.SV_ID
Minus
Select * from SchemaB.TableB order by SV_ID
Query is not working.
Kindly help me to find the difference between two tables , column by column based on the condition both of the tables have the same SV_ID.
Maybe you are looking for
-
OIM 9.1 DB Recon Changes Locked Account status in OIM back to Provisioned
Hi, I have a scheduled task that runs the OIM DBAccessReconTask but am seeing some unexpected behavior. Here are the steps to produce the error: 1. Provision a DB account to a user in OIM (this creates an account in the target database and the accoun
-
Forms Migration to 11g, RUN_PRODUCT must be declared
Hi All, I'm performing forms migration from 10g to 11g, I used Forms Migration Assistant to Migrate forms, But if a form is calling reports then those forms are not getting compiled and giving the error RUN_PRODUCT must be declared. I know that RUN_P
-
Acrobat Reader 9.2 Bug! Maybe!?
Hey all!First of all I am new to the forum and i'd like to take the chance to say Hello to averyone in this usefull forum! HELLO! I have just installed Acrobat reader 9.2 downloading from the website adobe.com. All went great and it worked fine. Tha
-
Music > Playlist > In all playlists songs are alpha listed and not grouped by album. I need songs track listed with gouped albums as the default view.
-
Seems we've lost the command, option, control ability to visually adjust brush hardness on the fly in PSCS5. Instead I get a seemingly useless color picker. Has this VERY USEFUL keyboard/mouse feature been reassigned or is it gone? Regards, kingdex