PL/SQL 안에서 DB_LINK 의 제한..
안녕하세요.
프로시져에서
if
aa@link1
else
aa@link2
else
aa@link3
else..
이렇게 DB_LINK 를 사용하고 있습니다.
그런데 이게 3개가 넘으면 에러가 나네요.
어느 문서에 보니 open_links 수를 늘려줘야 한다고 하는데
해결책이 맞나요?
그리고 맞다면 어떻게 늘려줄 수 있나요?
먼저 파라미터 값인 open_links의 갯수를 확인하시고
만약 변경을 해야 한다면
alter system set open_links=갯수 scope=spfile;
혹은 파라미터 파일에서 open_links 값을 변경한 후
디비 restart 시키셔야 합니다.
Similar Messages
-
V$SQL View underlying definition
HI
Is it possible to get underlying deifintion of v$views ? ( if i query text from dba_views i see v_$sql is selecting from v$sql)
I want to know what are the underlying tables used for v$sql.How can i find that
Thankssb92075 wrote:
894365 wrote:
HI
Is it possible to get underlying deifintion of v$views ? ( if i query text from dba_views i see v_$sql is selecting from v$sql)
I want to know what are the underlying tables used for v$sql.How can i find thatAny/all of the V$* "views" query SGA data structures & are presented as regular SQL Views.Which may be true, but doesn't answer his question.
The way it works is, let's take V$SQL as an example:
SQL> select owner,object_type,object_name from dba_objects where object_name='V$SQL';
OWNER OBJECT_TYPE OBJECT_NAME
PUBLIC SYNONYM V$SQL
SQL> So, V$SQL is actually a public synonym. Let's see what it points at:
SQL> exec print_table('select owner,synonym_name,table_owner,table_name,db_link from dba_synonyms where owner=''PUBLIC'' and synonym_name = ''V$SQL''');
OWNER : PUBLIC
SYNONYM_NAME : V$SQL
TABLE_OWNER : SYS
TABLE_NAME : V_$SQL
DB_LINK :
PL/SQL procedure successfully completed.Now, we can see that V$SQL is a public synonym that points to SYS.V_$SQL. Now, DBA_SYNONYMS says it's a table, but, it could also be a view. And, in this case, it is a view.
We can see that here:
SQL> exec print_table('select owner,object_type,object_name from dba_objects where owner=''SYS'' and object_name =''V_$SQL''');
OWNER : SYS
OBJECT_TYPE : VIEW
OBJECT_NAME : V_$SQL
PL/SQL procedure successfully completed.Ok, so V_$SQL is a view.
Let's see what it's definition is:
SQL> exec print_table('select text from dba_views where owner=''SYS'' and view_name = ''V_$SQL''');
TEXT : select
"SQL_TEXT","SQL_FULLTEXT","SQL_ID","SHARABLE_MEM","PERSISTENT_MEM","RUNTIME_MEM"
,"SORTS","LOADED_VERSIONS","OPEN_VERSIONS","USERS_OPENING","FETCHES","EXECUTIONS
","PX_SERVERS_EXECUTIONS","END_OF_FETCH_COUNT","USERS_EXECUTING","LOADS","FIRST_
LOAD_TIME","INVALIDATIONS","PARSE_CALLS","DISK_READS","DIRECT_WRITES","BUFFER_GE
TS","APPLICATION_WAIT_TIME","CONCURRENCY_WAIT_TIME","CLUSTER_WAIT_TIME","USER_IO
_WAIT_TIME","PLSQL_EXEC_TIME","JAVA_EXEC_TIME","ROWS_PROCESSED","COMMAND_TYPE","
OPTIMIZER_MODE","OPTIMIZER_COST","OPTIMIZER_ENV","OPTIMIZER_ENV_HASH_VALUE","PAR
SING_USER_ID","PARSING_SCHEMA_ID","PARSING_SCHEMA_NAME","KEPT_VERSIONS","ADDRESS
","TYPE_CHK_HEAP","HASH_VALUE","OLD_HASH_VALUE","PLAN_HASH_VALUE","CHILD_NUMBER"
,"SERVICE","SERVICE_HASH","MODULE","MODULE_HASH","ACTION","ACTION_HASH","SERIALI
ZABLE_ABORTS","OUTLINE_CATEGORY","CPU_TIME","ELAPSED_TIME","OUTLINE_SID","CHILD_
ADDRESS","SQLTYPE","REMOTE","OBJECT_STATUS","LITERAL_HASH_VALUE","LAST_LOAD_TIME
","IS_OBSOLETE","IS_BIND_SENSITIVE","IS_BIND_AWARE","IS_SHAREABLE","CHILD_LATCH"
,"SQL_PROFILE","SQL_PATCH","SQL_PLAN_BASELINE","PROGRAM_ID","PROGRAM_LINE#","EXA
CT_MATCHING_SIGNATURE","FORCE_MATCHING_SIGNATURE","LAST_ACTIVE_TIME","BIND_DATA"
,"TYPECHECK_MEM","IO_CELL_OFFLOAD_ELIGIBLE_BYTES","IO_INTERCONNECT_BYTES","PHYSI
CAL_READ_REQUESTS","PHYSICAL_READ_BYTES","PHYSICAL_WRITE_REQUESTS","PHYSICAL_WRI
TE_BYTES","OPTIMIZED_PHY_READ_REQUESTS","LOCKED_TOTAL","PINNED_TOTAL","IO_CELL_U
NCOMPRESSED_BYTES","IO_CELL_OFFLOAD_RETURNED_BYTES" from v$sql
PL/SQL procedure successfully completed.Huh? How can V_$SQL be based on V$SQL, when V$SQL is a synonym that points to V_$SQL??
Well, this is where the trick comes in. SYS.V$SQL is a fixed view, i.e. a view that is owned by SYS and starts with 'V$' or 'GV$'.
So, we can look at V$FIXED_VIEW_DEFINITION to see the definition of SYS.V$SQL:
SQL> exec print_table('select view_definition from v$fixed_view_definition where view_name = ''V$SQL''');
VIEW_DEFINITION : select SQL_TEXT , SQL_FULLTEXT , SQL_ID,
SHARABLE_MEM , PERSISTENT_MEM , RUNTIME_MEM , SORTS , LOADED_VERSIONS ,
OPEN_VERSIONS , USERS_OPENING , FETCHES , EXECUTIONS , PX_SERVERS_EXECUTIONS ,
END_OF_FETCH_COUNT, USERS_EXECUTING , LOADS , FIRST_LOAD_TIME, INVALIDATIONS,
PARSE_CALLS , DISK_READS , DIRECT_WRITES , BUFFER_GETS , APPLICATION_WAIT_TIME,
CONCURRENCY_WAIT_TIME, CLUSTER_WAIT_TIME, USER_IO_WAIT_TIME, PLSQL_EXEC_TIME,
JAVA_EXEC_TIME, ROWS_PROCESSED , COMMAND_TYPE , OPTIMIZER_MODE , OPTIMIZER_COST,
OPTIMIZER_ENV, OPTIMIZER_ENV_HASH_VALUE, PARSING_USER_ID , PARSING_SCHEMA_ID ,
PARSING_SCHEMA_NAME, KEPT_VERSIONS , ADDRESS , TYPE_CHK_HEAP , HASH_VALUE,
OLD_HASH_VALUE, PLAN_HASH_VALUE, CHILD_NUMBER, SERVICE, SERVICE_HASH, MODULE,
MODULE_HASH , ACTION , ACTION_HASH , SERIALIZABLE_ABORTS , OUTLINE_CATEGORY,
CPU_TIME, ELAPSED_TIME, OUTLINE_SID, CHILD_ADDRESS, SQLTYPE, REMOTE,
OBJECT_STATUS, LITERAL_HASH_VALUE, LAST_LOAD_TIME, IS_OBSOLETE,
IS_BIND_SENSITIVE, IS_BIND_AWARE, IS_SHAREABLE,CHILD_LATCH, SQL_PROFILE,
SQL_PATCH, SQL_PLAN_BASELINE, PROGRAM_ID, PROGRAM_LINE#,
EXACT_MATCHING_SIGNATURE, FORCE_MATCHING_SIGNATURE, LAST_ACTIVE_TIME, BIND_DATA,
TYPECHECK_MEM, IO_CELL_OFFLOAD_ELIGIBLE_BYTES, IO_INTERCONNECT_BYTES,
PHYSICAL_READ_REQUESTS, PHYSICAL_READ_BYTES, PHYSICAL_WRITE_REQUESTS,
PHYSICAL_WRITE_BYTES, OPTIMIZED_PHY_READ_REQUESTS, LOCKED_TOTAL, PINNED_TOTAL,
IO_CELL_UNCOMPRESSED_BYTES, IO_CELL_OFFLOAD_RETURNED_BYTES from GV$SQL where
inst_id = USERENV('Instance')
PL/SQL procedure successfully completed.So, SYS.V$SQL is based on GV$SQL. So, what's GV$SQL??
SQL> exec print_table('select owner,object_type,object_name from dba_objects where object_name =''GV$SQL''');
OWNER : PUBLIC
OBJECT_TYPE : SYNONYM
OBJECT_NAME : GV$SQL
PL/SQL procedure successfully completed.Another synonym?? Where does it all end?? (Hang in there, we're almost there!)
So, what does the GV$SQL synonym point to?
SQL> exec print_table('select * from dba_synonyms where owner=''PUBLIC'' and synonym_name = ''GV$SQL''');
OWNER : PUBLIC
SYNONYM_NAME : GV$SQL
TABLE_OWNER : SYS
TABLE_NAME : GV_$SQL
DB_LINK :
PL/SQL procedure successfully completed.Ok, so, now we have GV_$SQL. What's that, exactly? Is it really a table? Or perhaps another view?
SQL> exec print_table('select owner,object_type,object_name from dba_objects where owner=''SYS'' and object_name = ''GV_$SQL''');
OWNER : SYS
OBJECT_TYPE : VIEW
OBJECT_NAME : GV_$SQL
PL/SQL procedure successfully completed.Ok, so GV_$SQL is another view. Let's look at that definition!
SQL> exec print_Table('select text from dba_views where owner=''SYS'' and view_name = ''GV_$SQL''');
TEXT : select
"INST_ID","SQL_TEXT","SQL_FULLTEXT","SQL_ID","SHARABLE_MEM","PERSISTENT_MEM","RU
NTIME_MEM","SORTS","LOADED_VERSIONS","OPEN_VERSIONS","USERS_OPENING","FETCHES","
EXECUTIONS","PX_SERVERS_EXECUTIONS","END_OF_FETCH_COUNT","USERS_EXECUTING","LOAD
S","FIRST_LOAD_TIME","INVALIDATIONS","PARSE_CALLS","DISK_READS","DIRECT_WRITES",
"BUFFER_GETS","APPLICATION_WAIT_TIME","CONCURRENCY_WAIT_TIME","CLUSTER_WAIT_TIME
","USER_IO_WAIT_TIME","PLSQL_EXEC_TIME","JAVA_EXEC_TIME","ROWS_PROCESSED","COMMA
ND_TYPE","OPTIMIZER_MODE","OPTIMIZER_COST","OPTIMIZER_ENV","OPTIMIZER_ENV_HASH_V
ALUE","PARSING_USER_ID","PARSING_SCHEMA_ID","PARSING_SCHEMA_NAME","KEPT_VERSIONS
","ADDRESS","TYPE_CHK_HEAP","HASH_VALUE","OLD_HASH_VALUE","PLAN_HASH_VALUE","CHI
LD_NUMBER","SERVICE","SERVICE_HASH","MODULE","MODULE_HASH","ACTION","ACTION_HASH
","SERIALIZABLE_ABORTS","OUTLINE_CATEGORY","CPU_TIME","ELAPSED_TIME","OUTLINE_SI
D","CHILD_ADDRESS","SQLTYPE","REMOTE","OBJECT_STATUS","LITERAL_HASH_VALUE","LAST
_LOAD_TIME","IS_OBSOLETE","IS_BIND_SENSITIVE","IS_BIND_AWARE","IS_SHAREABLE","CH
ILD_LATCH","SQL_PROFILE","SQL_PATCH","SQL_PLAN_BASELINE","PROGRAM_ID","PROGRAM_L
INE#","EXACT_MATCHING_SIGNATURE","FORCE_MATCHING_SIGNATURE","LAST_ACTIVE_TIME","
BIND_DATA","TYPECHECK_MEM","IO_CELL_OFFLOAD_ELIGIBLE_BYTES","IO_INTERCONNECT_BYT
ES","PHYSICAL_READ_REQUESTS","PHYSICAL_READ_BYTES","PHYSICAL_WRITE_REQUESTS","PH
YSICAL_WRITE_BYTES","OPTIMIZED_PHY_READ_REQUESTS","LOCKED_TOTAL","PINNED_TOTAL",
"IO_CELL_UNCOMPRESSED_BYTES","IO_CELL_OFFLOAD_RETURNED_BYTES" from gv$sql
PL/SQL procedure successfully completed.Another GV$SQL?? Does this ever end???
Back to V$FIXED_VIEW_DEFINITION for the final round:
SQL> exec print_table('select view_definition from v$fixed_view_definition where view_name = ''GV$SQL''');
VIEW_DEFINITION : select inst_id,kglnaobj,kglfnobj,kglobt03,
kglobhs0+kglobhs1+kglobhs2+kglobhs3+kglobhs4+kglobhs5+kglobhs6+kglobt16,
kglobt08+kglobt11, kglobt10, kglobt01, decode(kglobhs6,0,0,1),
decode(kglhdlmd,0,0,1), kglhdlkc, kglobt04, kglobt05, kglobt48, kglobt35,
kglobpc6, kglhdldc, substr(to_char(kglnatim,'YYYY-MM-DD/HH24:MI:SS'),1,19),
kglhdivc, kglobt12, kglobt13, kglobwdw, kglobt14, kglobwap, kglobwcc, kglobwcl,
kglobwui, kglobt42, kglobt43, kglobt15, kglobt02, decode(kglobt32, 0,
'NONE', 1, 'ALL_ROWS', 2, 'FIRST_ROWS', 3, 'RULE',
4, 'CHOOSE', 'UNKNOWN'), kglobtn0, kglobcce, kglobcceh, kglobt17,
kglobt18, kglobts4, kglhdkmk, kglhdpar, kglobtp0, kglnahsh, kglobt46, kglobt30,
kglobt09, kglobts5, kglobt48, kglobts0, kglobt19, kglobts1, kglobt20, kglobt21,
kglobts2, kglobt06, kglobt07, decode(kglobt28, 0, to_number(NULL), kglobt28),
kglhdadr, kglobt29, decode(bitand(kglobt00,64),64, 'Y', 'N'), decode(kglobsta,
1, 'VALID', 2, 'VALID_AUTH_ERROR', 3, 'VALID_COMPILE_ERROR',
4, 'VALID_UNAUTH', 5, 'INVALID_UNAUTH', 6, 'INVALID'), kglobt31,
substr(to_char(kglobtt0,'YYYY-MM-DD/HH24:MI:SS'),1,19), decode(kglobt33, 1, 'Y',
'N'), decode(bitand(kglobacs, 1), 1, 'Y', 'N'), decode(bitand(kglobacs, 2), 2,
'Y', 'N'), decode(bitand(kglobacs, 4), 4, 'Y', 'N'), kglhdclt, kglobts3,
kglobts7, kglobts6, kglobt44, kglobt45, kglobt47, kglobt49, kglobcla,
kglobcbca, kglobt22, kglobt52, kglobt53, kglobt54, kglobt55, kglobt56,
kglobt57, kglobt58, kglobt23, kglobt24, kglobt59, kglobt53 -
((kglobt55+kglobt57) - kglobt52) from x$kglcursor_childSo, here we are, finally, we get to the fabled 'X$' table! An X$ table is hardcoded into the Oracle kernel, and it's a table projection of a chunk of the SGA memory. It's can't be updated, only queried, and is not subject to read consistency.
I'm sure this post will raise questions, but it's already too long, so, I'll leave it at that.
Feel free to ask follow up questions, and I'll try to address them.
Hope that helps,
-Mark -
ORA-00604: error occurred at recursive SQL when calling proc via db_link
Hi,
I'm on 9.2.0.8 and got strange issue with simple test case
on source db:
CREATE OR REPLACE PROCEDURE ADMIN.gg_ref(out_tokens OUT SYS_REFCURSOR) is
BEGIN
OPEN out_tokens for select dummy from dual;
END ;
Now testing code localy:
SQL> var r refcursor
SQL> declare
2 output sys_refcursor;
3 begin
4 adminx.gg_ref(output);
5 :r:=output;
6 end;
7 /
PL/SQL procedure successfully completed.
SQL> print r
D
X
So its working.
I've got db_link to that db , and now call that proc via dblink from other 9.2.0.8 DB:
var r refcursor
1 declare
2 output sys_refcursor;
3 begin
4 admin.gg_ref@LINK_NAME(output);
5 :r:=output;
6* end;
SQL> /
declare
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-00900: invalid SQL statementWhats wrong with my code ?
Are there any restriction I'm not aware of ?
Regards
GregGGregG wrote:
What should my code look like now ?
Should I rewrite this as function returning index by collection or something ?You can use DBMS_SQL - but use the remote package and not the local one. This is a little bit more complex ito call interface than using a ref cursor, but is the very same thing on the server side. DBMS_SQL also provides a more comprehensive set of features than using the ref cursor interface.
The main issue though is additional coding - as DBMS_SQL is a lower level interface (a lot closer to the real Oracle Call Interface/OCI):
--// on remote database the procedure returns a DBMS_SQL cursor instead of a ref cursor
SQL> create or replace procedure FooProc( cur in out number, deptID number ) is
2 rc number;
3 begin
4 cur := DBMS_SQL.open_cursor;
5
6 DBMS_SQL.parse(
7 cur,
8 'select ename from emp where deptno = :deptID',
9 DBMS_SQL.native
10 );
11
12 DBMS_SQL.Bind_Variable( cur, 'deptID', deptID );
13
14 rc := DBMS_SQL.Execute( cur );
15 end;
16 /
Procedure created.
--// from the local database side we call this remote proc
SQL> declare
2 c number; --// instead of using sys_refcursor
3 empName varchar2(10); --// buffer to fetch column into
4 begin
5 FooProc@testdb( c, 10 ); --/ call the proc that creates the cursor
6
7 --// we need to define our fetch buffer for the 1st column in the
8 --// SQL projection of that cursor (10 byte fetch buffer for 1st column)
9 DBMS_SQL.define_column@testdb( c, 1, empName, 10 );
10
11 --// we now fetch from this cursor, but via the DBMS_SQL
12 --// interface
13 loop
14 --// fetch the row (exit when 0 rows are fetched)
15 exit when DBMS_SQL.Fetch_Rows@testdb( c ) = 0;
16
17 --// copy value of 1st column in row into the local PL/SQL buffer
18 DBMS_SQL.column_value@testdb( c, 1, empName );
19
20 --// record value it via dbms output
21 DBMS_OUTPUT.put_line( 'name='||empName||' deptID=10' );
22 end loop;
23
24 --// close it explicitly as you would a ref cursor
25 DBMS_SQL.Close_Cursor@testdb( c );
26 end;
27 /
name=CLARK deptID=10
name=KING deptID=10
name=MILLER deptID=10
PL/SQL procedure successfully completed.
SQL> -
Db_link name and synonym in PL/SQL block
Hi,
I'm having a problem with synonyms in PL/SQL block.
Say, I have two schemas A and B.
In schema A, I create some tables and stored procedures.
In schema B, I create a db link connecting to schema A. Then I create some synonyms for tables and stored procedures in schema A with the db link. In stored procedures created in schema B, I need to access or reference objects in schema by using synonyms.
My problem is, if schema A and schema B reside on the same db instance and the instance's global_names is set to true, I will not be able to reference any synonyms in stored procedures created in schema B. The error message is,
PL/SQL: ORA-00980: synonym translation is no longer valid.
A simple example:
In schema A,
create table mytable (A char(2));
In schema B,
create database link <global_name-for-schema-A>@loopback connect to A identified by <A-pwd> using '<net-service-name-for-schema-A>';
create synonym mytable for mytable@<global_name-for-schema-A>@loopback;
declare
a char;
begin
select * from mytable;
end;
But I have no problem to access the synonym-ed objects in SQL*PLUS.
Please help.
ThanksI had the similar problem i did a work around like below
SQL>select max(col1) from tab1;
MAX(COL1)
21161910
SQL>get a
1 declare
2 a number;
3 begin
4 select max(col1) into a from tab1;
5 dbms_output.put_line(a);
6* end;
SQL>@a
select max(col1) into a from tab1;
ERROR at line 4:
ORA-06550: line 4, column 1:
PL/SQL: ORA-00980: synonym translation is no longer valid
ORA-06550: line 4, column 1:
PL/SQL: SQL Statement ignored
Created a view on top of the synonym
SQL>create or replace view tab1_v as select * from tab1@db1;
View created.
changed the pl/sql block as below to get it from view instead of synonymn
declare
a number;
begin
select max(col1) into a from tab1;
dbms_output.put_line(a);
end;
Now it worked
SQL>@a
21161910
PL/SQL procedure successfully completed. -
PL/SQL report errors: ORA-01422
Hi all,
(before i you read i would like to say i have searched the net for this error code but nothing shows up like this problem..)
I am getting an error problem when i select certain Schemas from a list on an apex app. page, it only works for some schemas not all..
When i select one schema, it is supposed to display one row.. when i select [ALL] it is supposed to show them all.
It does work if i select '[ALL]' from the select list (p3_schema_name), just not for every single individual one.
the error code:
ORA-01422: exact fetch returns more than requested number of rows
declare
vSchema varchar2(20);
vStmt varchar2(1000);
vVersion number(5);
vDBName varchar2(20);
vHostName varchar2(80);
vStmt2 varchar2(1000);
vVersion2 number(5);
vDBName2 varchar2(20);
vServer2 varchar2(80);
vSchema2 varchar2(80);
CURSOR c_schemas IS
select owner from dba_tables@P3_DB_NAME.db_link where table_name = 'DDL_LOG' and num_rows > 0 order by owner;
begin
IF :P3_SCHEMA_NAME != '[ALL]' AND :P3_DB_NAME IS NOT NULL AND :P3_SERVER_NAME IS NOT NULL THEN
vServer2 := :P3_SERVER_NAME;
vSchema2 := :P3_SCHEMA_NAME;
vStmt2 := 'select distinct DDH_DB_NM, max(DDH_SCHEMA_NR)keep(dense_rank last order by ddh_runstart_td) AS "PATCH" from &P3_SCHEMA_NAME..ddl_log@&P3_DB_NAME.db_link GROUP BY DDH_DB_NM';
Execute Immediate vStmt2 into vDBName2, vVersion2;
htp.p('<br>');
htp.p('<table border="1">');
htp.p('<tr>');
htp.p('<th bgcolor="#FFCC99">SERVER NAME</th>');
htp.p('<th bgcolor="#FFCC99">DB NAME</th>');
htp.p('<th bgcolor="#FFCC99">SCHEMA NAME</th>');
htp.p('<th bgcolor="#FFCC99">PATCH</th>');
htp.p('</tr>');
htp.p('<tr>');
htp.p('<td>');
htp.p(vServer2);
htp.p('</td>');
htp.p('<td>');
htp.p(vDBName2);
htp.p('</td>');
htp.p('<td>');
htp.p(vSchema2);
htp.p('</td>');
htp.p('<td>');
htp.p(vVersion2);
htp.p('</td>');
htp.p('<td>');
htp.p('<BR>');
htp.p('</td>');
htp.p('</tr>');
htp.p('</tr>');
htp.p('</table>');
ELSE IF :P3_SCHEMA_NAME = '[ALL]' AND :P3_DB_NAME IS NOT NULL AND :P3_SERVER_NAME IS NOT NULL THEN
vHostName := :P3_SERVER_NAME;
vDBName := :P3_DB_NAME;
open c_schemas;
htp.p('<br>');
htp.p('<table border="1">');
htp.p('<tr>');
htp.p('<th bgcolor="#FFCC99">SERVER NAME</th>');
htp.p('<th bgcolor="#FFCC99">DB NAME</th>');
htp.p('<th bgcolor="#FFCC99">SCHEMA NAME</th>');
htp.p('<th bgcolor="#FFCC99">PATCH</th>');
htp.p('</tr>');
LOOP
FETCH c_schemas INTO vSchema;
EXIT WHEN c_schemas%NOTFOUND;
vStmt := 'select max(DDH_SCHEMA_NR)keep(dense_rank last order by ddh_runstart_td) AS "PATCH" from '||vSchema||'.ddl_log@&P3_DB_NAME.db_link where DDH_SCHEMA_NR = (select max(DDH_SCHEMA_NR) from '||vSchema||'.ddl_log@&P3_DB_NAME.db_link) and rownum < 2' ;
Execute Immediate vStmt into vVersion ;
htp.p('<tr>');
htp.p('<td>');
htp.p(vHostName);
htp.p('</td>');
htp.p('<td>');
htp.p(vDBName);
htp.p('</td>');
htp.p('<td>');
htp.p(vSchema);
htp.p('</td>');
htp.p('<td>');
htp.p(vVersion);
htp.p('</td>');
htp.p('<td>');
htp.p('<BR>');
htp.p('</td>');
htp.p('</tr>');
END LOOP;
htp.p('</tr>');
htp.p('</table>');
CLOSE c_schemas;
END IF;
END IF;
END;I have checked the DDH_SCHEMA_NR for repeating entries of the highest number.. some of the ones that dont work do have repeating entries some don't.
Sorry if this is confusing, i have tried to explain it as best as i can.
Thanks in advance for any help.
AshleighHello Ashleigh,
Based on your code, I'd start by running this piece of SQL via command-line (thru SQL Workshop, SQL*Plus, Toad, etc.), replacing &P3_SCHEMA_NAME. and &P3_DB_NAME. with values that are currently causing the routine to fail and see if it returns more than one row. I don't know your data, but DISTINCT and GROUP BY are typically used to return multiple (though grouped/summarized) rows. It appears to be the only statement that would cause the error your seeing (more than one row being returned into single variables).
select distinct DDH_DB_NM, max(DDH_SCHEMA_NR)keep(dense_rank last order by ddh_runstart_td) AS "PATCH" from &P3_SCHEMA_NAME..ddl_log@&P3_DB_NAME.db_link GROUP BY DDH_DB_NM;I'm actually surprised that the code runs at all. I didn't think 'execute immediate' would know what to do with substitutions indicated as "&something." (I've typically seen that when substituting in dynamic HTML/Javascript code but maybe I'm learning something new). But since you already have vServer2 and vSchema2, I'd be more apt to code it as:
vStmt2 := 'select distinct DDH_DB_NM, max(DDH_SCHEMA_NR)keep(dense_rank last order by ddh_runstart_td) AS "PATCH" from ' ||
vSchema2 || '.ddl_log@' || vServer2 || '.db_link GROUP BY DDH_DB_NM';Hope this helps,
John -
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? -
Error When Using DataBase LINK in pl/sql
I have cursor fetching some values from remote db and i m trying to store values in local table (see code below) I can run the select query alone succefully but when i use it inside plsql it fails with error.
DECLARE
TYPE MY_CURSOR
IS
REF
CURSOR;
THE_CURSOR MY_CURSOR;
V_CT NUMBER(18);
V_PSN_ID VARCHAR2(30);
V_INTERNET_ID VARCHAR2(75);
BEGIN
V_CT :=0;
OPEN THE_CURSOR FOR SELECT PSN_ID, 'TEST' FROM TABLE_A@PRO1 WHERE TABLE_A.SEQ_A<=1000;
LOOP
FETCH THE_CURSOR INTO V_PSN_ID, V_INTERNET_ID;
EXIT
WHEN THE_CURSOR%NOTFOUND;
INSERT INTO PSN_EMAIL_SENT_TO@local
(PSN_ID, LAST_UPDT_DT
) VALUES
(V_PSN_ID, SYSDATE
V_CT:=V_CT+1;
END LOOP;
CLOSE THE_CURSOR;
DBMS_OUTPUT.PUT_LINE
TO_CHAR(V_CT)
END;
Error report:
ORA-04052: error occurred when looking up remote object TABLE_A@PRO1
ORA-00604: error occurred at recursive SQL level 1
ORA-04029: error ORA-1775 occurred when querying ORA_KGLR7_DEPENDENCIES
ORA-00604: error occurred at recursive SQL level 1
ORA-01775: looping chain of synonyms
ORA-02063: preceding 3 lines from PRO1
04052. 00000 - "error occurred when looking up remote object %s%s%s%s%s"
*Cause: An error has occurred when trying to look up a remote object.
*Action: Fix the error. Make sure the remote database system has run
KGLR.SQL to create necessary views used for querying/looking up
objects stored in the database.You need to create the catalog views that support distributed SQL in your remote database (the database you connect to via db_link).
To create these views, connect "/ as sysdba" and run:
$ORACLE_HOME/rdbms/admin/catproc.sql
which will in turn call several other scripts including: $ORACLE_HOME/rdbms/admin/catrpc.sql (which creates your missing view)
It is best to run the whole catproc.sql script (and not just the catrpc script).
You can run and rerun catproc.sql several times quite safely.
Cheers -
ORA-31600 when trying to view SQL DDL for a created public database link
I created and committed a public database link and I can access the external database.
When I try to view the DDL of the link, on the SQL tab, I'm getting following error:
ORA-31600: invalid input value EMIT_SCHEMA for parameter NAME in function SET_TRANSFORM_PARAM
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 105
ORA-06512: at "SYS.DBMS_METADATA_INT", line 3900
ORA-06512: at "SYS.DBMS_METADATA_INT", line 4048
ORA-06512: at "SYS.DBMS_METADATA", line 836
ORA-06512: at line 1
and
ORA-31600: invalid input value LONGNAME for parameter NAME in function SET_FILTER
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 105
ORA-06512: at "SYS.DBMS_METADATA_INT", line 1980
ORA-06512: at "SYS.DBMS_METADATA_INT", line 3665
ORA-06512: at "SYS.DBMS_METADATA", line 670
ORA-06512: at "SYS.DBMS_METADATA", line 571
ORA-06512: at "SYS.DBMS_METADATA", line 1221
ORA-06512: at line 1
Is this because of a bug in SqlDeveloper or because the db_link and host parameters have 33 characters?
I'm using sql developer 1.5.3, build MAIN-5783
tx,
Roger VermeirIt's probably the length; really all sqldev does is calling:
select DBMS_METADATA.get_ddl('DB_LINK',:NAME,:OWNER) FROM dual;So if you call it a bug, it's a database bug in the DBMS_METADATA package.
But if you work with identifiers over 30 chars, I'd say that's a bug on it's own...
FWIW, I can't reproduce this on our 10g DB; are you on 9i?
Regards,
K. -
Db link error in PL/SQL but not in SQL
oracle 10.2.0.4
solaris 10
I have a simple procedure (anonymous block) that uses a db link to update a table in another db (on same host)
The procedure fails with the following error:
ORA-02019: connection description for remote database not found
I can insert records using the same db_link using the exact same line pasted from the stored proc (same line that raises the ORA-02019).
insert into table_x@my_db_link (select * from local_table_y);
x rows inserted
I use the same sql*plus session to run both the stored proc and sql command;
SQL> conn my_user/my_pwd
connected
SQL> @my_proc.sql
ORA-02019: connection description for remote database not found
SQL> insert into table_x@my_db_link (select * from local_table_y);
x rows inserted
QUESTION:
Why does the db_link fail in the procedure and not the sql command line call?
P.S.
I converted the procedure to a store proc and it also fails with the same call.Perhaps if the Database link is non-public?There is a bug, #3240720, which applies when the owner of the db link is not the user who's executing the query.
There are several bugs which demonstrate this sort of behaviour. For instance ORA-2019 can be hurled if the local PL/SQL is running against a remote Dataguard standby database (although I would hope we wouldn't be running an INSERT in that scenario).
Cheers, APC
blog: http://radiofreetooting.blogspot.com -
Connecting to SQL 2005 from Oracle error
I have an Oracle Database and SQL Database on the same server and wants to use odbc to connect to the SQL 2005 database and query tables of my choice.
I did configured the ODBC correctly and called the DSN TSH_ARCHIVE. I have tested it and it works great. But each time I run the following query I get error:
SQL> select count(*) from BALANCES_HS@tse_archive;
select count(*) from BALANCES_HS@tse_archive
ERROR at line 1:
ORA-12154: TNS:could not resolve the connect identifier specified
Any suggestion and help will be greatly appreciated.
Edited by: azaza on Jan 28, 2010 6:32 AMHi,
Thanks for the files.
There are some problems with the configuration.
listener.ora -
LISTENERTSE_ARCHIVE =
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST = xxxxx.ita.doc.gov)(PORT=1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(SID_NAME=TSE_ARCHIVE)
(ORACLE_HOME=J:\app\product\11.1.0\db_2)
(PROGRAM=hsodbc)
(SID_DESC=
(SID_NAME=tpisdb06)
(ORACLE_HOME=J:\app\product\11.1.0\db_2)
This should be -
LISTENERTSE_ARCHIVE =
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST = xxxxx.ita.doc.gov)(PORT=1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
SID_LIST_LISTENERTSE_ARCHIVE =
(SID_LIST=
(SID_DESC=
(SID_NAME=TSE_ARCHIVE)
(ORACLE_HOME=J:\app\product\11.1.0\db_2)
(PROGRAM=dg4odbc)
(SID_DESC=
(SID_NAME=tpisdb06)
(ORACLE_HOME=J:\app\product\11.1.0\db_2)
The SID_LIST_LISTENER needs to match the actual listener name and the program for 11g DG4ODBC is called dg4odbc and not hsodbc.
tnsnames.ora -
TSE_ARCHIVE =
(DESCRIPTION=
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = TSE_ARCHIVE)(PORT=1521))
(CONNECT_DATA =
(SERVICE_NAME = TSE_ARCHIVE)
(HS=OK)
The HOST name - TSE_ARCHIVE does not match the HOST in the listener, so it should be -
TSE_ARCHIVE =
(DESCRIPTION=
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = xxxxx.ita.doc.gov)(PORT=1521))
(CONNECT_DATA =
(SERVICE_NAME = TSE_ARCHIVE)
(HS=OK)
I've changed the actual name to xxxxx so replace that with the name in the original file.
Change the files, stop and start the listener then try again.
If you still have an ora-12154 error then send the output from the following SQL -
select db_link, host from user_db_links; <=== as the user getting the error
and
select db_link, host from dba_db_links; <===== as a DBA user
Regards,
Mike -
Using CASE in a dynamic sql query
Hi,
I want to create a dynamic query using the CASE statement to replace the below 2 SQL statements:
+++++
select 'create or replace synonym '|| SYNONYM_NAME || ' for '||TABLE_OWNER||'.'||TABLE_NAME||'@'||SUBSTR(db_link,1,30)||' ;' FROM USER_SYNONYMS where db_link is not null;
select 'create or replace synonym '|| SYNONYM_NAME || ' for '||TABLE_OWNER||'.'||TABLE_NAME||' ;' FROM USER_SYNONYMS where db_link is null;
+++++
So that i have a single select query which will give the create synonym statements for all with/without db links
Using the CASE statement example like given below :
SELECT
FirstName, LastName,
Salary, DOB,
CASE Gender
WHEN 'M' THEN 'Male'
WHEN 'F' THEN 'Female'
END
FROM Employees
I am not getting how to write this CASE statement. Can someone guide me here?
Thanks,
KunwarKunwar wrote:
I am a Junior Oracle DBA. I would like to master SQL & PL/SQL concepts & tricks. Please guide me some books (apart from the oracle documentation links) which will improve my SQL & PL-SQL skills which are very weak right now. Personnally I started with the Oracle Class Training SQL&PL/SQL, then did a loooooooooooot of reading on [url http://asktom.oracle.com]AskTom (I even bought his book).
Also I tried (and I'm still trying) to answer to SQL/PLSQL problematic on this forum, then tried to see and learn from what other gave as answers.
I also spend and spent a lot of time in the Oracle Documentation. (I fear your "apart from the oracle documentation" to actually mean : apart reading the documentation)
Kunwar wrote:
TOAD alternative for create ddl statements for limited no. of objects
You need to learn to use dbms_metadata. I gave you an example, use the documentation and some self-testing to make it do what you need.
"Practice makes perfect"
And as an hint : To become a SQL & PL/SQL Master, you should first start by forgetting Toad : The real tool for learning is SQL*Plus.
Toad, as any tool, is only good in the hands of whom knows what they do and how things work. -
Select type_address in Portal report's sql query using remote database
how do i select type_address item from remote database table ?
I've already create the database link called db_link.
I've already execute the sql statement in the specified database, and it works.
for example: ( sql plus in the specified database )
select syk.alamat_syarikat.alamat1 from MCS_SYARIKAT syk
for example: ( sql statement in portal report using database link )
select nama_syarikat, syk.alamat_syarikat.alamat1 from MCS_SYARIKAT@dblink syk
error massage:
Unable to describe SQL statement. Please correct it (WWV-13010)
Invalid SQL statement: select syk.alamat_syarikat.alamat1 from MCS_SYARIKAT@dblink syk (WWV-13005)
ORA-01001: invalid cursor (WWV-11230)
ORA-22804: remote operations not permitted on object tables or user-defined type columns (WWV-11230)
Failed to parse as MCS_PUBLIC - select syk.alamat_syarikat.alamat1 from MCS_SYARIKAT@dblink syk (WWV-08300)Here's the actual query:
SELECT BUILD_EXT_RES_LIST(EXT_FILE.ID) A
FROM EXT_FILE_RES, EXT_FILE
WHERE EXT_FILE_RES.ON_OWNER_PROFILE = 'Y' AND
EXT_FILE.OWNER_ID = :PROFILE AND
EXT_FILE.ID = EXT_FILE_RES.EXT_ID AND
(RES_SUBSCRIBER_YN(EXT_FILE.ID,:CURR_ID) = 'YES' OR
ADMINYESNO(:CURR_ID,:PROFILE) = 'YES')
ORDER BY EXT_FILE.FILE_NAMEAnd here's the actual error message:
1 error has occurred
Query cannot be parsed within the Builder. If you believe your query is syntactically correct, check the ''generic columns'' checkbox below the region source to proceed without parsing. ORA-00904: "SER_IS_ADMINYESNO": invalid identifier -
Hi gurus,
just wondering whether this sql works fine.
Insert into contact_history@demo (narrative) select substrb(narrative,1,4000) from CONTACT_HISTORY
where I in (select i from missing_ivalue)
where demo is a dblink for source and the target database and narrative is a column name which is varchar2(4000)
contact_history@demo is a target table.
i actually need to insert complete record which has missing i value with the substrb(narrative,1,4000)
any suggestion is highly apprciated
Thanks
Edited by: 790072 on 8/02/2011 15:54
Edited by: 790072 on 16/08/2011 19:56Hi,
790072 wrote:
Insert into toccontact_history@demo (narrative) select substrb(narrative,1,4000) from TOCCONTACT_HISTORY
where I in (select i from missing_ivalue)
where demo is a dblink for source and the target database and narrative is a column name which is varchar2(4000)
toccontact_history@demo is a target table.As per your post,the above insert statement will absolutely work fine,unless if you have insert permission for toccontact_history table,to your present schema,where you are executing the insert statement.Also you need to have db link created to access the tables,created in other schema.
Check the db_link created by using the query
select * from user_db_linksIts always suggested to post a sample data to understand your requirement cleary and we can try to provide you a solution to your problem.
Hope this helps.
Regards,
Achyut -
Hi All,
We have an oracle 8i database and an MS Sql Server 2000 db. These two communicate with each other using some ODBC connection.
From Oracle SQLPLUS, I am able to query object that are in the MS Sql Server but the problem is that the query (select object_name from all_objects@db_link) returns rows only for 15 minutes. If i write the same query (being in the same session of sqlplus) it says no rows selected. Somehow, i think, the connection times out. What could be the problem?
Thanksdepends from the operating system and the odbc driver vendor.
On Windows you commonly need to call the ODBC Administrator and enable MACHINE WIDE tracing.
On Unix OS you commonly have to add an ODBC section to the odbc.ini file containig:
Trace=1
TraceFile=/tmp/odbctrace.out
Make sure the odbc trace file is written to a directory the oracle user has sufficient privileges. -
Syntax for checking DBMS_METADATA.GET_DDL('DB_LINK'')
i am using oracle 8i any suggestion in syntax here?
SQL> Select DBMS_METADATA.GET_DDL('DB_LINK',p140.ngco.com,'PPRUSR') FROM dual;
Select DBMS_METADATA.GET_DDL('DB_LINK',p140.ngco.com,'PPRUSR') FROM dual
ERROR at line 1:
ORA-00904: invalid column name
BANNER
Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production
PL/SQL Release 8.1.7.4.0 - Production
CORE 8.1.7.0.0 Production
TNS for IBM/AIX RISC System/6000: Version 8.1.7.4.0 - Production
NLSRTL Version 3.4.1.0.0 - Production1. The DB_LINK name must be enclosed by quotes
2. DBMS_METADATA is not available on 8.1.7 Oracle version.
Nicolas.
Maybe you are looking for
-
I am unable to store my username & password for email accounts.
this article was not able to help me: https://support.mozilla.org/en-US/kb/usernames-and-passwords-are-not-saved#firefox:win7:fx27 i tried the password manager settings, but did not see a list of sites in the exceptions list! the "always use private
-
New to LR 5.2 Running OS X 10.8.5. Tried to save image in file folder. Now get this message at top of all images in Library: "File could not be found." How do I fix this?
-
Consolidate All Windows option not functional in Illustrator CC 2014
I just downloaded the Illustrator CC 2014 update, and I cannot for the life of me consolidate all my open documents to one window. In other words I want to dock all open documents to the top in tabs. In the regular CC version, if you have multiple do
-
Help please.
-
Hello, I have still another question, sorry I need a field for expenses. With this I mean that the employee is able to entry if this recorded time is valid for expenses or not. Do I have a user definded field and if yes how to implement it? Thx, Va