Sleep function in oracle
is there any function to stop the procedure for 0.01 secs??
i want that precision.
thank you,
regards,
chintan
Hi Alex,
I tried that...
and now if i try to compile my procedure, it throws error that DBMS_LOCK must be defined..I am using 9.i..
and do dba has to give me privilege for
connect as sys, grant execute on dbms_lock to <user>. ???
please let me know.
Thank you,
Regards,
Chintan
Similar Messages
-
Need help in using sleep function in pl/sql
Hi,
need help:
I have a condition where i want to validate total_pass=total_fail and
I want to use the sleep function in a pl/sql where i want to wait for 2 minutes ie.checking
whether total_pass=total_fail based upon class_id .
I have the data in the table as:
CLASS_ID TOT_PASS TOT_FAIL
1 10 10
2 5 4
3 6 6
4 7 5
Any help will be needful for meI'm not quite sure what you are lookg for here, but whatever it is, your code as posted won't do it. You will never break out of the WHILE r_Class.Tot_Pass = r_Class.Tot_Fail loop, since these values will never change because you never get the next record form the cursor.
From your original data, it looks like your cursor will return multiple rows which implies to me that you want to fetch the first row from the cursor, check if tot_pass = tot_fail, if they are equal, sleep for two minutes then get the next row. This does not make sense to me. Once the select in the cursor is executed, the data it returns will not change due to Oracle's read consistency model, so there seems to me no point in the sleep.
The other alternative I can see is that you want to check all the returned rows, and if tot_pass = tot_fail for one of the rows (or possibly for all of the rows), then you want to sleep and try again.
If you can explain in words what it is you are trying to accomplish, someone will be able to point you to a solution.
John -
Hi Guys,
I am creating a procedure which will check for the fileld in the database and if it returns NULL should go to sleep for 15 minutes and then will again check for the field. I am planning to use DBMS_LOCK.SLEEP function. Please can you suggest if the same is fine or advise if in case there is any other specific function which I require to use as I have read that the mentioned function is not accurate in calculating the SLEEP time.
[http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:6019886867656]
Best Regards,
ShazSummary of DBMS_LOCK Subprograms
Table 53-3 DBMS_LOCK Package Subprograms
Subprogram Description
ALLOCATE_UNIQUE Procedure
Allocates a unique lock ID to a named lock.
CONVERT Function
Converts a lock from one mode to another.
RELEASE Function
Releases a lock.
REQUEST Function
Requests a lock of a specific mode.
SLEEP Procedure
Puts a procedure to sleep for a specific time.
PL/SQL lock timer
Definition: This Wait-Event represents the amount of time a user or application has “slept” through the USER_LOCK.SLEEP or DBMS_LOCK.SLEEP procedures.
When investigating Oracle Wait-Events, the lion's share of time is spent looking at those events where applications consume precious system resources or are in direct contention with other users or applications. These resource waits revolve around excessive CPU, memory, or disk usage. Events that spin for Oracle internal structures such as latches or enqueues can also be of concern. As their name suggests, Wait-Events DO ‘wait’ on some event to complete before a user or application can continue with its work. Contention for system resources will overwhelm Oracle’s ability to immediately process the SQL and ultimately cause applications to accumulate time in resource specific Wait-Events.
On the flip-side of resource waits there are what are called idle events. These events do not wait for any specific resource but record the time Oracle is waiting for a work request from the application. Many practitioners of Oracle performance will not even look at these idle events because they do not consume resources and are not limiting what Oracle can do at any given point in time. Some will even go so far as to state that the idle events have no meaningful information. This is not necessarily true. Take for instance the idle event ‘SQL*Net message from client’. This idle event is not inhibiting the database server from performing work but, as many agree, is an indication of poor response from client to database server. While idle events are not the result of direct resource contention, they are an accurate measure of accumulated delays in the application imposed by Oracle.
The ‘idle’ event “PL/SQL lock timer” is worth watching because it points us in the direction of application response, throughput, and possible coding issues. The PL/SQL lock timer event is, as the command that issues it states, a sleep mandated by the application code. The application is idle and doing nothing. This means that if the application sleeps for a combined interval of 5 minutes, the response to the user or complete run of the application will take at least 5 minutes longer.
While this event does not require resources and thus is not an Oracle resource contention issue, it is our job to provide the quickest response to users and push applications through our system to increase the user’s perceived performance.
Most often, sleeps are put into an application for serialization of transactional events or spinning on queues until something happens. When the event occurs or a queue is populated, then the application continues its work. We should ask ourselves why an application is sleeping for any amount of time and provide alternatives if necessary to reduce this idle event. You will gain quicker responses if you trigger an action instead of the action waiting for an event.
How to look at the PL/SQL lock timer event
To initiate a sleep for the current session for five seconds.
SQL> execute sys.dbms_lock.sleep(5);
To take a look at current sessions that are using the SLEEP command. Notice that the column P1 in V$SESSION does not represent the amount of time the session has slept but in fact represents the duration this session will sleep. Also note that this column is in centiseconds and as such the five seconds issued for a sleep has been translated in to 500 centiseconds.
SQL> select osuser,event,p1 from v$session where event = 'PL/SQL lock timer'
OSUSER EVENT P1
Johnny Smith PL/SQL lock timer 500 -
Since I installed Lion on my macbook the LED light does not pulse when I close the screen - the sleep function does not work neither when chosen after pressing the button nor chosen in the apple menu..
I have had the same problem but on another forum it was suggested that disabling internet sharing would solve this. This fix seems to work on my machine - why it works I do not understand
-
External FW/USB Western Digital, Seagate Disk Drives and 'Sleep' function
As you are aware, most external disk drives be they FW or USB (and irrespective of the manufacturer, save for LaCie) have a 'sleep' function built into their Firmware. In the case of the Western Digital and Seagate Ext FW drives I have, this function cannot be disabled and this per both WD and Seagate.
Unfortunately this is extremely annoying if using Photoshop and Bridge...it takes about ten seconds for each disk to spin up while the latter programs search the drives. (In Windows this can be enabled/disabled. Not so with the Mac O/S I have been told). Multiply this by six of the aforementioned drives and it can be quite time consuming.
Is there an OS-X workaround for this?
Thanks again,
LymanI always avoid vendor cases. Might want to look at an Oxford 912 etc, or better yet, why use Firewire when eSATA works so well?
-
Subpartition with MOD Function in Oracle 11g
Hi All,
Can we create Subpartition based on MOD Function in Oracle 11g ?Hi!
What are you refering with "MTS"? Anybody knows a term like this (except MultiThreaded Server). -
제품 : PL/SQL
작성날짜 : 2001-09-11
RANK FUNCTION IN ORACLE 8I
==========================
EXPLANATION
oracle 8i(8.1.6) 부터 가능한 rank function 입니다.
8.1.5 에서는 ora-923 error 가 납니다.
plsql 내에서는 oracle 9i 부터 가능합니다.
8.1.6에서는 ora-900 error가 납니다.
EXAMPLE
<RANK() OVER ( query_partition_clause ORDER_BY clause) >
- 중복 rank 값만큼 다음 순위는 생략
SQL>SELECT deptno, ename, sal, comm,
RANK() OVER (PARTITION BY deptno ORDER BY sal DESC, comm) as rk
FROM emp;
DEPTNO ENAME SAL RK
10 KING 5000 1
10 CLARK 2450 2
10 MILLER 1300 3
20 3500 1
20 SCOTT 3000 2
20 FORD 3000 2
20 JONES 2975 4
20 ADAMS 1100 5
20 SMITH 800 6
30 BLAKE 2850 1
30 ALLEN 1600 2
30 TURNER 1500 3
30 WARD 1250 4
30 MARTIN 1250 5
40 JAMES 777 1
9 1
<DENSE_RANK( ) OVER ( query_partition_clause ORDER_BY clause ) >
- 중복 rank 의 수와 무관하게 numbering
SQL>SELECT dname, ename, sal, DENSE_RANK()
OVER (PARTITION BY dname ORDER BY sal) as drank
FROM emp, dept
WHERE emp.deptno = dept.deptno
AND dname IN ('SALES', 'RESEARCH');
DNAME ENAME SAL DRANK
RESEARCH SMITH 800 1
RESEARCH ADAMS 1100 2
RESEARCH JONES 2975 3
RESEARCH SCOTT 3000 4
RESEARCH FORD 3000 4
RESEARCH 3500 5
SALES WARD 1250 1
SALES MARTIN 1250 1
SALES TURNER 1500 2
SALES ALLEN 1600 3
SALES BLAKE 2850 4
plsql 내에서 사용 가능 :oracle 9i 부터
SQL> create table
rank_emp(deptno number(2), ename varchar2(20), sal number(5), rk number(2));
테이블이 생성되었습니다.
SQL> create or replace procedure window_plsql AS
query_str VArchar2(1000);
begin
query_str := 'insert into rank_emp
SELECT deptno, ename, sal,
RANK() OVER (PARTITION BY deptno ORDER BY sal DESC, comm) as rk
FROM emp' ;
Execute Immediate query_str;
end;
2 /
프로시저가 생성되었습니다.
SQL> exec window_plsql
PL/SQL 처리가 정상적으로 완료되었습니다.
SQL> select * from rank_emp;
DEPTNO ENAME SAL RK
10 KING 5000 1
10 CLARK 2450 2
10 MILLER 1300 3
20 SCOTT 3000 1
20 FORD 3000 1
20 JONES 2975 3
20 ADAMS 1100 4
20 SMITH 800 5
30 BLAKE 2850 1
30 ALLEN 1600 2
30 TURNER 1500 3
DEPTNO ENAME SAL RK
30 WARD 1250 4
30 MARTIN 1250 5
30 JAMES 950 6
14 개의 행이 선택되었습니다.That's correct
The differences between Standard and Enterprise Edition are listed here:
http://www.oracle.com/technology/products/oracle8i/pdf/8i_fam.pdf -
Function in oracle to find number of occurances of a character in a string
hi,
is there any function in oracle to find the number of ocurrances of a character in a string ?
or is there any simple way of doing the same, rather than writting many lines of code as my program is already very complex.
MariaHi Maria,
I don't know of such a function in Oracle, but maybe you could use this:
length(search_string) - length(replace(search_string, character_to_be_found))
For example: select length('Hello') - length ( replace('Hello', 'l')) from dual;
Hope this is what you're looking for
Danny -
Use T-SQL functions in ORACLE too, so you can write one script version that works in SYBASE, SQLSERVER and ORACLE when need to use the following functions:
ceiling, charindex, dateadd, datediff, datename, datepart, day, db_id, db_name, getdate, host_id, host_name, left, len, month, replicate, right, space, str, str_replace, stuff, substring, suser_id, suser_name, user_id, user_name and year.
The file [comp_tsql_ORA_schema.txt|http://forums.databasejournal.com/attachment.php?attachmentid=564&d=1258547015] creates the tablespace and schema to put the objects, and the file [comp_tsql_ORA.txt|http://forums.databasejournal.com/attachment.php?attachmentid=569&d=1259256898] creates the functions into the new schema. They will be avaliable for any schema of the oracle instance.
Hope this help!
Any suggestion please contact.
aklein2003
Edited by: user1958693 on 26/11/2009 10:16jgarry wrote:
J2EE beta released around 1999. Religious programming wars far preceded that. Here's but [one example|http://groups.google.com/group/comp.lang.lisp/browse_thread/thread/1c50bc13e9302f00/34bb8f3ac77e2388?q=programming+language+religion#34bb8f3ac77e2388] from a quick google. I'm no longer convinced that elegance is a desirable trait for a language. So call me a heretic.
Ever tried XLISP? :-)
It's different. Back then it was simply the language itself. And it was not really a religious kind of battle, but more a mine-is-bigger-and-better-than-yours one.
With Java, it is all about The Acrhitecture and the blessed language of Java. ;-)
I wouldn't so much blame J2EE believers for that. I think there is a fundamental complexity to web type paradigms that hasn't been described in a precise and encompassing enough manner to enable correct project planning.The basic problem is that the database is treated as a persistent storage layer only. A bit bucket. And that is exactly what a database is not.
But as it is used that, loads of database features now need to be duplicated in the application layer. Which is done. Very poorly.
Heck, I've even been told that J2EE's 3-tier architecture is not client server. Such ignorance is really unbelievable. Or is it pure stupidity?Until you just made me look it up, I would have thought that too, I'm sure I saw client/server defined as two-tier in the last century. But I have much more stupid misdefinitions to deal with on a daily basis, simply from the multiplicity of paradigms. I tend to retreat into my shell. Hehehe. Know that feeling... These days I rather run away, or set shields to full power, than try to get in yet another frustrating, fruitless and futile discussion with a Java head about the wonders of the J2EE architecture. Or trying to explain that this "new" architecture is predated with what we used in the 80's on mainframe systems with transaction monitors, block devices (the 80's web browsers) and databases - which software layer for software layer was almost identical to "+The Great Architecture+" of today. (and we did it without buzzwords too) ;-)
Client-server is a software architecture and in essence describes 3 basic software components. The User Interface (UI), the Application (APP) and the Database (DB). And there are various ways to put these components together in a client-server architecture. The mistake that the Java fanbois make is thinking that client-server means having the client as the UI and APP as a single component (so-called fat client) and then the DB component as the server.
There are numerous versions of these - including the APP component being a server component (as we now these days more commonly used in over the web).
My beef with the J2EE "+religion+" always has been that client-server is client-server. The fundamentals stay the same. -
Using FILTER function in oracle answers
Gurus,
I have a question related to using Filter function in oracle answers.
When trying to insert a Filter (expr) Using (expr) clause in the formula area of a fact table field, It errored out with msg saying about using a wrong measure.
I know this can be done with a case expression but I tried filter clause since this is available in oracle answers.
Please help me figuring out this scenario.
Thanks.David / Raghu - Thanks for u'r replies and apologizes for not posting question with proper material.
Am posting my code and the error message from the screen.
Code :
IFNULL(FILTER("Fact - MBS Loan Transactions"."OUTSTANDING PRINCIPAL" USING "Dim - MBS Loan"."LOAN TYPE HPD/HDC/BNK" = 'HDC'),0)
Error :
nQSError: 10058] A general error has occurred. [nQSError: 22032] Function FILTER requires at least one measure attribute in its first argument. (HY000)
SQL Issued: SELECT "Dim - MBS Loan"."LOAN AMOUNT", "Dim - MBS Loan"."LOAN TYPE HPD/HDC/BNK", "Dim - MBS Loan"."LOAN TYPE SEN/SUB", "Dim - MBS Project"."PROJECT NAME", "Dim - MBS Project"."PROJECT NUMBER", "Fact - MBS Loan Transactions"."AR BALANCE INTEREST", "Fact - MBS Loan Transactions"."GL BALANCE INTEREST", IFNULL(FILTER("Fact - MBS Loan Transactions"."OUTSTANDING PRINCIPAL" USING "Dim - MBS Loan"."LOAN TYPE HPD/HDC/BNK" = 'HDC'),0) FROM "Financials - MBS"
OK (Ignore Error)
Please continue answering my queries. Since am a newbie your answers won't be just a reply but it's actually learning for me.
Thanks. -
I can't use the sleep functions, is it a bug?
i just updated my Ipod to 1.2 .And i found the sleep function is not available. there is no menu to set the sleep time. when i put the sleep menu , my nano turns off immediately. is it a software bug?
i have had the answer.
the sleep function can't be used as a sleep timer.the sleep timer is set in clock menu. -
How to create SSWA plsql function in Oracle Apps of HTML call .html
Hello Team,
I am working on Oracle Apps 11i (11.5.10.2)
I want to know , what is the process to create a , "SSWA plsql function" in Oracle Apps of type "HTML" and html call tab.
How to create that Function and how to attach the PL/SQL code to these functions.
How it works.
Please help me to understand this concept from basics.
Kind RegardsHi;
Please review:
how to setup a forms function in R12 to launch an URL?
http://www.trutek.com/serendipity/index.php?/archives/15-An-Example-of-How-to-Create-Custom-Functions,-Menus,-and-Responsibilities.html
Regard
Helios -
Need Assistance for VBA function in oracle how to implement
My very respected and Senior, regards,
Sir, hope you will in best of health and wealth by the grace of God,
Sir, i have a request problem as i m very junior against you and you have passed this time before many years ago as i m standing where. Sir i m a very junior developer of oracle and have a problem putting on your desk with the hope that you can help my as a boss.
Sir me have to calculate yield of Bond using oracle form
i have tried my best and tired
there is a formulae in excel which give the Yield() when we provide the parameters
and i need the excel formulae or the oracle calculation code of PLSQL for this.
How can i get yield when i have price, coupon rate, frequency, issue and maturity of the coupon , coupon period , next coming coupon , and others detail.
or tell me how to use EXCEL VBA for this problem ,
thnx n regards,
yours student, junior developer youngest brother
Faraz
How can I get the solution using Excel VBA function with oracle
so that move values to excel calculate them and copy the result from excel to oracle formsHi,
for the Hex-Number-conversion see:
[url http://psoug.org/snippet/Convert-Hex-to-Decimal-Decimal-to-Hex_78.htm] self-defined Conversion-Functions
What number format do you have? YYYMMDD
Or is there a Date corresponding to 1 and a number n represent the date n-1 days after day 1?
Please describe further.
Bye
stratmo -
How I work with MS-SQL function in oracle
I’m working in oracle now but I don’t know how can I use following function in oracle.
convert, dateadd, datediff, fetch_status, isnumeric, reverse, str and stuffAlso available in 10g, the model clause version, taken from this How to display text in reverse order ?.
WITH t AS (SELECT 'abcdefg' col1
FROM DUAL
UNION
SELECT ''
FROM DUAL )
SELECT col1
, new_col1
FROM t
MODEL
PARTITION BY (ROWNUM rn)
DIMENSION BY (0 dim)
MEASURES (col1, CAST ('' AS VARCHAR2(255)) new_col1)
RULES ITERATE(99) UNTIL (LENGTH(new_col1[0]) = LENGTH(col1[0]))
(new_col1[0] = SUBSTR(col1[0], ITERATION_NUMBER + 1, 1) || new_col1[0])
COL1 NEW_COL1
abcdefg gfedcbaC. -
Equivalent of DB2 functions in ORACLE 11g
Hi,
I am trying to convert the SQL queries written in DB2 to ORACLE. There are some db2 specific functions are used in the queries.I am not able to find the equivalent function in ORACLE. The function names are written below:
1) DateDD()
2) SELECT @@IDENTITY
3) SELECT *
FROM (
SELECT ROWNUMBER() OVER() AS rowId_1, INNER_TABLE.*
FROM (----)as innertable
) AS Outertable
Error is: ROWNUMBER is INVALID identifier.
4) DAYOFWEEK()
5) DAYS()
6) dayofyear()
Please help me in finding the equivalent function in ORACLE.
Thanks in advance!!You probably don't need a DateAdd function in Oracle. You can add a number to a date in Oracle-- that adds the number of days to the date.
SELECT sysdate today, sysdate+1 tomorrow
FROM dualWhy are you using DAYS()? If, as in the example, you're just trying to determine the number of days between two dates, you can subtract dates in Oracle and the difference will be a number of days (including a fractional component if applicable)
SELECT date '2011-09-27' - date '2011-09-25' difference_in_days
FROM dualIf you really need the number of days since January 1, 0001, you could subtract the date from Jan 1, 0001, i.e.
SELECT date '2011-09-27' - date '0001-01-01'
FROM dualI would assume that Oracle and DB2 would return the same number but there could well be some differences since the current calendar didn't exist in the year 1 and I know there were issues in the transition from the Gregorian to the Julian calendar where some days were decreed not to exist. It wouldn't shock me if Oracle and DB2 counted some of the days in the 1500's differently.
Justin
Maybe you are looking for
-
How can I update Camera Raw in Photoshop CC 2014?
I purchased and installed Creative Cloud Photography Plan two weeks ago. I have Photoshop CC 2014.0.0 release. The Camera Raw plug in is 8.0.0.137. The Creative Cloud Desktop app says that Photoshop CC (2014) is up to date. The updates link in Pho
-
After downloading the new OS X Yosemite my computer has been lagging, how can I fix this?
-
My VI code uses the VI's that came with the NI USB-8451 USB-to-SPI converter. Before compiling I needed to use one of those VI's to select the particular USB device that I'm trying to address, then I click the Run button. But after I compile my c
-
IOS 7 - Change message bubble color?, IOS 7 - Change message bubble color?
I'm guessing we still can't change the message bubble colors? It was just annoying before. Now it is a necessity. The vivid green/white on a white background just makes it hard to see/read for SMS messages...I can go as far as saying that it hurts
-
C7 setting card in use for Internet downloads
Is it possible to set which card and folder Internet downloads are saved to? BBC iPlayer downloads seem to be saved to the root of the mass memory card and I cannot see any way of changing this. I want to change this to my Kingston memory card.