How to search source of pl/sql block in database?
Hi Guys,
We have an issue in database, there is PL/SQL block running in my database as below which deleting very important historical data.
begin
loop
delete from tabl_name where created_date<sysdate -100 and ronum<10000;
EXIT WHEN SQL%NOTFOUND;
commit;
end loop;
end;
I tried following,
1) I found this block in v$sqlarea
2) I searched in dba_source,user_source,all_source but no luck.
3) I checked all the triggeres but no luck.
4) I checked all the cron entries for oracle/root/app owner in os but no luck.
5 I checked all the jobs in dba_jobs but no lcuk
would appreciated if anyone can assist on this.
I want to disable/remove this query to be executed.
Regards,
Rikki
For ASH,
I am trying to confirure the OEM and not able to access the OEM from remotely. However any idea from commad prompt.
I believe there is a script ashrpt.sql but while running this script format is not supporting.
any idea if you have run it before.
I agree for log miner utilities, but I need to configure the UTL dir and need to bounce it and its a critical production environment so looking for alternatives. if not possible I would go for this option.
It seems ASH report is being geneated lets see how does it go.
Regards,
Pradeep
Edited by: user13049723 on Jul 26, 2010 8:07 PM
Similar Messages
-
How to pass parameter to pl/sql block
Hi,
I am getting following error when trying to create staging table from shell script by passing parameter.
SQL*Loader-941: Error during describe of table T1_1DAY_STG
ORA-04043: object T1_1DAY_STG does not existThis is PL/SQL block being called inside shell script
begin
execute immediate 'create table t1_&1._stg as select * from t1_rpt_tmt';
endShell Script Call
load_data_to_oracle()
for i in 1DAY 7DAY 15DAY
do
${ORACLE_HOME}/bin/sqlplus ${ORACLE_USER}/${ORACLE_PASSWD}@${ORACLE_SID} << EOF > ${TMP_LOG_FILE} 2>&1
set serveroutput on
@${CREATE_STAGE_SQL} "$i"
COMMIT;
QUIT;
EOF
########Main#######
load_data_to_oraclethanks
sandyi dont understand why you want run it from shell script. you can write procedure like this :
SQL>
SQL> CREATE OR REPLACE PROCEDURE mytestProc(p_in VARCHAR2) AS
2 begin
3 FOR i IN (select REGEXP_SUBSTR(p_in,'[^,]+',1,ROWNUM) tblName
4 from dual
5 CONNECT BY INSTR(p_in, ',', 1, level - 1) > 0)
6 LOOP
7 execute immediate 'create table t1_'||i.tblname||'_stg as select * from myt2';
8 END LOOP;
9 end;
10 /
Procedure createdand run it
SQL> exec mytestProc('1day,7day,15day');
PL/SQL procedure successfully completed
SQL> select * from t1_15day_stg
2 union all
3 select * from t1_1day_stg
4 union all
5 select * from t1_7day_stg;
T N
SQL>
SQL> drop table t1_15day_stg;
Table dropped
SQL> drop table t1_1day_stg;
Table dropped
SQL> drop table t1_7day_stg;
Table dropped
SQL> purge table t1_15day_stg;
Done
SQL> purge table t1_1day_stg;
Done
SQL> purge table t1_7day_stg;
Done
SQL> -
How to re-execute anonymous PL/SQL block in package definition ?
Hi all,
I implemented a package which contains procedures and an anonymous PL/SQL block.
This anonymous PL/SQL block is executed only once when the package is called.
and charge in-memory the content of table to avoid multiple SQL access each
time one procedure is called.
As my application open many sessions to the Oracle database, I would like to try
a solution to signal all sessions to reload the content of table when the content
of table is modified. The solution to stop and to restart the connection is not
acceptable.
Best regards
Sylvain> .. to avoid multiple SQL access each time one procedure is called.
As I understand your posting, this is the actual technical requirement. You want to force serialisation of PL/SQL code. Correct? (only one session at a time can run the procedure)
This feature typically used to accomplish this in o/s code is called a semaphore. PL/SQL does not specifically support semaphores. However, it supports a range of IPC (Inter Process Communication) methods - from message queues to pipes.
One of these IPC interfaces is DBMS_LOCK - which allows a unique lock to be defined and processes to manage their resource usage/execution/etc via this lock using the DBMS_LOCK API.
I've found this a pretty clean and manageable solution to enforce serialisation. Of course, it is even better not to enforce serialisation. Rather design the code to be thread safe and capable of multi-processing/parallel processing.
Personally, I would not use a table as an IPC mechanism as Oracle already provides better IPC mechanisms for PL/SQL code. As for "signalling sessions to re-load the table" - not possible as Oracle sessions cannot register callbacks to handle events. Oracle sessions are not event driven processes from a PL/SQL (application development) perspective. -
How To Create User through Pl SQL Block
Want to create user from pl sql block using dynamic SQl. Used dbms_sql package . But when I run the block it does not recognises the parameter v7 which is a constant in dbms_sql package. Message displayed is Can not access parameter from package being restricted procedure.
Is there any method to create user through PL SQl blockhi ranjit,
hope this will work
declare
uname varchar2(30):=&uname;
pword varchar2(30):=&pword;
begin
execute immediate ('grant connect, resource to '| |uname| |' identified by '| |pword);
end;
regards -
How can i connect to a SQL Server 2000 database usgin JSP?
I need (URGENT) to connect to SQL Server 2000 databse using JSP. I do not know how to program using JSP, so if anyone has any code snippet please let me see it. What i need is to give my site some login/password security.
Anyone?
Thx.just create an ODBC of your database from control pannel -> administrative tools -> data sources (ODBC) ,double click it .....
go to the tab SYstem DSN , click on ADD button. select the driver for your connection. it will be the last one in the list "SQL Server".
click Next then give ur DSN name there, description and Server Name , on next give your username and password of SQL server. when it will be connected to the server celect your database from there and hence there will be an ODBC bridge same as in case of MS Access.
code for connecting to ODBC is
// DSN-NAME same as in System DSN.
// username and password are of your databse
try
url = "jdbc:odbc:DSN-NAME";
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
connect = DriverManager.getConnection( url,"username","password" );
catch ( ClassNotFoundException cnfex ) {
setErrorMsg( cnfex.getMessage() );
catch ( SQLException sqlex ) {
setErrorMsg( sqlex.getMessage() );
catch ( Exception ex ) {
setErrorMsg( ex.getMessage() );
Now you are connected to the SQL Server ..... use connect object for further processing ......... -
PL/SQL block on new jdbc connection
Can someone please suggest, how can we execute a pl/sql block whenever a new connection is established in weblogic server.
tried setting InitSQL value in jdbc source as: SQL exec pkg.func() but it didn't worked and server failed to start.
Any suggestion?Hi,
That's interesting. Could this also work for the Test Table statement? And, if so, what should the block do to make the test fail? Raise an exception?
Thanks,
Sebastien -
Hi Masters,
I was attended one technical interview two days back. The interviewer asked me the below pl/sql output and explain the process. I said it won't give any error and answer also. He is not happy with execution process.
Please find below pl/sql block. Please explain me how control will execution the pl/sql block?
begin
v_sal numbber(5);
select sal into v_sal
from emp
where deptno=60;
exception
when no_data_found then
do something;
end;
begin
something;
something;
exception
when others then
something;
end;
Please advise...!!
Thanks in adv.
ArHere's what happens:
SQL> begin
2
3 v_sal numbber(5);
4
5 select sal into v_sal
6 from emp
7 where deptno=60;
8
9 exception
10
11 when no_data_found then
12 do something;
13
14 end;
15
16 begin
17
18 something;
19 something;
20
21 exception
22
23 when others then
24 something;
25
26 end;
27 /
v_sal numbber(5);
ERROR at line 3:
ORA-06550: line 3, column 10:
PLS-00103: Encountered the symbol "NUMBBER" when expecting one of the following:
:= . ( @ % ;
The symbol ":=" was substituted for "NUMBBER" to continue.
ORA-06550: line 12, column 17:
PLS-00103: Encountered the symbol "SOMETHING" when expecting one of the following:
:= . ( @ % ;
The symbol ":=" was substituted for "SOMETHING" to continue.
ORA-06550: line 16, column 5:
PLS-00103: Encountered the symbol "BEGIN" -
Conditional where, or PL/SQL block as source for an interactive report?
I have this situation: The main screen of my application shows a list of documents. For now, there has to be a quick "security" built in, so administrators can see all documents, but other users can only see the documents they created (login of creator is stored in the documents table). In the future we'll probably use VPD's to enforce some rules, but for now we need a quick solution.
So i stored the administrators in a seperate table. Now i want the interactive report on the main page act as follows:
- If an admin is logged in, it has to have this query: select field 1, field 2, field 3 from documents
- For all other users: select field 1, field 2, field 3 from documents where creator = :app_user
Is this possible in one interactive report? I could make two reports with the different queries and make them conditional according to who is logged in, but this gives me two interactive reports to maintain. Is it possible to use a PL/SQL block as source for the report? I tried, but I get syntax errors. Is it possible to make the where clause conditional on some way?Hi,
Install Demonstration application to your workspace:
Home>Create Application and select Demonstration Application.
Check page 1 interactive report. That should give idea how you do it.
Br, Jari -
How to test for différent Select into a single PL/SQL block ?
Hi,
I am relatively new to PL/SQL and I am trying to do multiple selects int a single PL/SQL block. I am confronted to the fact that if a single select returns no data, I have to go to the WHEN DATA_NOT_FOUND exception.
Or, I would like to test for different selects.
In an authentification script, I am searching in a table for a USER ID (USERID) and an application ID, to check if a user is registered under this USERID for this APPLICATION.
There are different possibilities : 4 possibilities :
- USERID Existing or not Existing and
- Aplication ID found or not found for this particular USERID.
I would like to test for thes 4 possibilities to get the status of this partiular user regardin this application.
The problem is that if one select returns no row, I go to the exception data not found.
In the example below you see that if no row returned, go to the exception
DECLARE
P_USERID VARCHAR2(400) DEFAULT NULL;
P_APPLICATION_ID NUMBER DEFAULT NULL;
P_REGISTERED VARCHAR2(400) DEFAULT NULL;
BEGIN
SELECT DISTINCT(USERID) INTO P_USERID FROM ACL_EMPLOYEES
WHERE USERID = :P39_USERID AND APPLICATION_ID = :APP_ID ;
:P39_TYPE_UTILISATEUR := 'USER_REGISTERED';
EXCEPTION
WHEN NO_DATA_FOUND THEN
:P39_TYPE_UTILISATEUR := 'USER_NOT_FOUND';
END;I would like to do first this statement :
SELECT DISTINCT(USERID) INTO P_USERID FROM ACL_EMPLOYEES
WHERE USERID = :P39_USERID Then to do this one if the user is found :
SELECT DISTINCT(USERID) INTO P_USERID FROM ACL_EMPLOYEES
WHERE USERID = :P39_USERID AND APPLICATION_ID = :APP_ID ;etc...
I basically don't want to go to the not found exception before having tested the 4 possibilities.
Do you have a suggestion ?
Thank you for your kind help !
ChristianSurely there are only 3 conditions to check?
1. The user exists and has that app
2. The user exists and doesn't have that app
3. The user doesn't exist
You could do this in one sql statement like:
with mimic_data_table as (select 1 userid, 1 appid from dual union all
select 1 userid, 2 appid from dual union all
select 2 userid, 1 appid from dual),
-- end of mimicking your table
params_table as (select :p_userid userid, :p_appid appid from dual)
select pt.userid,
pt.appid,
decode(min(case when dt.userid = pt.userid and dt.appid = pt.appid then 1
when dt.userid = pt.userid then 2
else 3
end), 1, 'User and app exist',
2, 'User exists but not for this app',
3, 'User doesn''t exist') user_app_check
from mimic_data_table dt,
params_table pt
where pt.userid = dt.userid (+)
group by pt.userid, pt.appid;
:p_userid = 1
:p_appid = 2
USERID APPID USER_APP_CHECK
1 2 User and app exist
:p_userid = 1
:p_appid = 3
USERID APPID USER_APP_CHECK
1 3 User exists but not for this app
:p_userid = 3
:p_appid = 2
USERID APPID USER_APP_CHECK
3 2 User doesn't exist -
How to use the WHENEVER SQLERROR EXIT statement in a PL/SQL block.
Hi,
I am getting the following error when trying to add the following statement in an PL/SQL block.
WHENEVER SQLERROR EXIT SQL.SQLCODE
[exec] ERROR at line 23:
[exec] ORA-06550: line 23, column 12:
[exec] PLS-00103: Encountered the symbol "SQLERROR" when expecting one of the
[exec] following:
[exec] := . ( @ % ;
How can i use the above statement in the PL/SQL Block? I have only IF statement in that block( between BEGIN and END).
ThanksHi,
Usually there's always more than one solution.
Can you post an example of what you're trying to accomplish?
That would be useful.
(Place the tag before and after your example to maintain formatting en spacing, see the [fac|http://forums.oracle.com/forums/help.jspa] regarding available tags) -
How to print/store in file the ref cursor in pl/sql block ?
How to print/store in file the ref cursor in pl/sql block ?.
How to print/store in file the ref cursor in pl/sql block ?.You question is quite confusing?
So, i'm providing link in this manner.
For RefCursor,
http://www.oracle-base.com/articles/misc/UsingRefCursorsToReturnRecordsets.php
http://www.oracle.com/technology/oramag/code/tips2003/042003.html
For UTL_FILE,
http://www.morganslibrary.org/reference/utl_file.html
Regards.
Satyaki De.
Updated with new morgan library link.
Edited by: Satyaki_De on Feb 24, 2010 9:03 PM -
How to convert pl/sql block into single update statement
Dear all gurus,
I have pl/sql block mention below, Can I convert this pl/sql block to single update statement if possible?
If not how to optimize this block?
Pleaese suggest.
thanks in advance.
Vijay
DECLARE
CURSOR vt_mlr_cursor IS Select master_key, user4 from vt_mlr Where USER4 is not null;
USERFIELD VARCHAR2(100);
C1 VARCHAR2(3); /* this will return location of first space = 12 */
C2 VARCHAR2(3); /* this will return location of second space = 20 */
C3 VARCHAR2(3); /* this will return location of third space = 28 */
C4 VARCHAR2(3); /* this will return location of forth space = 35 */
Field1 VARCHAR2(40); /* this will return FTMYFLXA04W */
Field2 VARCHAR2(10); /* this will return VPI0043 */
Field3 VARCHAR2(10); /* this will return VCI0184 */
Field4 VARCHAR2(10); /* this will return 005 */
Field5 VARCHAR2(10); /* this will return 00001 */
Field_2_n_3 VARCHAR2(25);
key VARCHAR2(10);
BEGIN
FOR vt_mlr_record IN vt_mlr_cursor
LOOP
key := vt_mlr_record.master_key;
USERFIELD := vt_mlr_record.user4;
C1 := INSTR(vt_mlr_record.user4,' ',1,1); /* this will return location of first space = 12 */
C2 := INSTR(vt_mlr_record.user4,' ',1,2); /* this will return location of second space = 20 */
C3 := INSTR(vt_mlr_record.user4,' ',1,3); /* this will return location of third space = 28 */
C4 := INSTR(vt_mlr_record.user4,' ',1,4); /* this will return location of forth space = 35 */
Field1 := SUBSTR(vt_mlr_record.user4,1,C1-1); /* this will return FTMYFLXA04W */
Field2 := SUBSTR(vt_mlr_record.user4,C1+4,C2-C1-4); /* this will return VPI0043 */
Field3 := SUBSTR(vt_mlr_record.user4,C2+4,C3-C2-4); /* this will return VCI0184 */
Field4 := SUBSTR(vt_mlr_record.user4,C3+4,C4-C3-4); /* this will return 005 */
Field5 := SUBSTR(vt_mlr_record.user4,C4+4,LENGTH(vt_mlr_record.user4)-C4-3); /* this will return 00001 */
Field_2_n_3 := Field2 || '/' || Field3;
/*DBMS_OUTPUT.PUT_LINE ('Current key is: ' || vt_mlr_record.master_key);*/
UPDATE vt_mlr
SET
aggregator_clli = Field1,
aggregator_vpi_vci = Field_2_n_3,
aggregator_slot = Field4,
aggregator_port = Field5
WHERE
master_key = vt_mlr_record.master_key;
END LOOP;
END;
/Hi Vijay,
Here's something to start with, you should be able to complete it.
First, combine your select and update statements:
update vt_mlr
set aggregator_clli = field1
,aggregator_vpi_vci = field_2_n_3
,aggregator_slot = field4
,aggregator_port = field5
where user4 is not null;Then put these two
C1 := INSTR(vt_mlr_record.user4,' ',1,1);
Field1 := SUBSTR(vt_mlr_record.user4,1,C1-1);into
Field1 := SUBSTR(vt_mlr_record.user4,1,INSTR(vt_mlr_record.user4,' ',1,1) -1);And put it into the update statement, removing reference to record
(I have also removed default values for position and occurrence in instr function):
update vt_mlr
set aggregator_clli = substr(user4, 1, instr(user4,' ') - 1)
,aggregator_vpi_vci = field_2_n_3
,aggregator_slot = field4
,aggregator_port = field5
where user4 is not null; I think you can do the rest from here ;-)
Regards
Peter -
How to search a term in the source code
Hello ,
How to search a term in the source code. I have selection screen , on which a program name will be given and term to search. How can I proceed to know whether this term is available in the source code of the program
Thanks and regards,
SatyaHi naga,
1. one option is to retrive the source code of the requried program,
into internal table using the syntax READ REPORT (just see f1 help on it)
READ REPORT prog INTO itab [MAXIMUM WIDTH INTO wid].
2. Then we can loop / search the internal table for the required term.
regards,
amit m. -
Using PL/SQL Block how do you check if the character string value is aA-zZ
I have a pl/sql block that I prompt the user for password and I load the string into an array and interrogate each index(entry) to see if it is "aA-zZ".
How can I check if the value entered is Alpha.
I need to do the same for number and Special character. Please advise. ThanksThanks to All of you. The desired solution to verify complex password that enforces desired security policies. An example that I am using is the following:
IF NOT (regexp_like(sz_complex_pw,'[[:digit:]]') AND regexp_like(sz_complex_pw,'[[:alpha:]]') AND regexp_like(sz_complex_pw,'[[:punct:]]') AND regexp_like(sz_complex_pw,'[[:upper:]]'))
THEN
--dbms_output.put_line('Password is not complex...');
RAISE sz_err_pw_complex; -- Complex Password is not compliant
END IF;
DBMS_OUTPUT.PUT_LINE('Complex Password is in Compliance...');
EXCEPTION
This was helpful to me and I trust others will find helpful.
Edited by: yakub21 on Oct 16, 2010 9:05 PM -
Q: how can i write PL/SQL block to check prerequisite?
Hello...
I designed an application using sql*plus statment for creating database and developer for creating forms, for on-line registration system for universties,
so I need to teach me how can I write pl/sql block to check the prerequisite, taken courses, and complete hours for the students who wants register the courses via Internet.
thanks alot in advance
kindly send the answers a.s.a.pplease repost this in the SQL & PL/SQL forum
thanks - OTN
Maybe you are looking for
-
Cisco prime infrastructure 1.3
Hi Experts, i am currently try to explore cisco prime Infra 1.3 and facing some problem. 1 : i have set the admin password at startup config but this password is not working(i am pretty sure that i have enter the same password) 2: Can i change the pr
-
Forum, I would like to know the superscript font name (to create TM trade mark and SM service mark) in reports 6 thanks natarajan.
-
Hey guys, I'm setting up a report in which I'm using a filter on user role. Two roles are selected hard-coded. Besides this I'm using user name with a variable. Now I would like to see only those names linked to the two roles. Currently all names bel
-
Different between work order closed and completed
HI experts I would like to know what is different between closed work order and completed on SAP PM Module. regards nasser
-
Intel/Non Intel Tiger install mix up on HD replacement
Objective: On an iMac intel trying to simply swap out an original 250GB internal drive that died with a 1TB and re-instal Tiger. *Situation Now*: Booting off the original install disks for this intel iMac, when get to the select destination drive scr