Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> dblink in PL/SQL block..
hi all,
I have one small problem. Below is my query which is running on the sql prompt:
*select username||'('||sid||','||serial#||') ospid = ' || process ||'
program = ' || program username,to_char(LOGON_TIME,' Day HH24:MI')
logon_time,to_char(sysdate,' Day HH24:MI') current_time,sql_address,
LAST_CALL_ET from **v$session_at_tmoldb_cochin* <v$session_at_tmoldb_cochin> *where
status = 'ACTIVE' and rawtohex(sql_address) <> '00' and username is not null
order by last_call_et;*
but when I am using the same sql in the PL/SQL block as below:
*create or replace procedure showsql as
-- x number;
cursor c1 is
select username||'('||sid||','||serial#||
') ospid = ' || process || ' program = ' || program username, to_char(LOGON_TIME,' Day HH24:MI') logon_time, to_char(sysdate,' Day HH24:MI') current_time, sql_address, LAST_CALL_ET from v$session_at_tmoldb_cochin where status = 'ACTIVE' and rawtohex(sql_address) <> '00' and username is not null order by last_call_et;cursor c2 is
max(decode(piece,1,sql_text,null)) || max(decode(piece,2,sql_text,null)) || max(decode(piece,3,sql_text,null)) sql_text from v$sqltext_with_newlines_at_tmoldb_cochin where address = x.sql_address and piece < 4;
for x in c1 loop
for y in c2 loop if ( y.sql_text not like '%listener.get_cmd%' and y.sql_text not like '%RAWTOHEX(SQL_ADDRESS)%') then dbms_output.put_line( '--------------------' ); dbms_output.put_line( x.username ); dbms_output.put_line( x.logon_time || ' ' || x.current_time|| ' last et = ' || x.LAST_CALL_ET); dbms_output.put_line( substr( y.sql_text, 1, 250 ) ); end if; end loop;
Warning: Procedure created with compilation errors.
SQL> sho err
Errors for PROCEDURE SHOWSQL:
LINE/COL ERROR
-------- ----------------------------------------------------------------- 4/2 PL/SQL: ORA-04052: error occurred when looking up remote object SYS.V_$SESSION_at_TMOLDB_COCHIN.ONEAPPS.COM ORA-02030: can only select from fixed tables/views 4/2 PL/SQL: SQL Statement ignored 15/2 PL/SQL: SQL Statement ignored 21/37 PL/SQL: ORA-00904: "X"."SQL_ADDRESS": invalid identifier26/13 PL/SQL: Statement ignored
-- Thanks & Regards, T. Onkar Nath OneAPPS Enterprise Technology Pvt. Ltd. to_onkar_at_yahoo.com onkarnath.tiwary_at_gmail.com -- http://www.freelists.org/webpage/oracle-lReceived on Mon Jan 23 2006 - 01:22:10 CST
![]() |
![]() |