Where current of

Hi
Please explain me about WHERE CURRENT OF clause.
Also please let me know about why WHERE CURRENT OF NO UPDATE is used.
Thanks in advance
Manju

amazing what they document nowadays:
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/sqloperations.htm#sthref1510

Similar Messages

  • Need help to generate "where current of" from ODBC

    Hi
    I am trying to develop a small stand-alone program which uses Oracle Drivers.
    I have installed PERL and came up with a code (structure) like below
    But I dont know how to use the current cursor reference with a statement
    This is what I came up with
    use Win32::ODBC;
    my($db) = new Win32::ODBC("dsn=TEST_DSN; uid=TEST; pwd=TEST");
    $db->SetStmtOption(SQL_CURSOR_TYPE,SQL_CURSOR_KEYSET_DRIVEN);
    $db->SetStmtOption(SQL_ROWSET_SIZE,10);
    $db->SetCursorName("abc");
    $cursth = $db->prepare('SELECT * FROM pos_update_table testupdate where val=1 FOR UPDATE');
    $cursth->execute;
    print $db->GetCursorName;
    while ($cursth->fetch) {
    $updsth = $db->prepare("update pos_update_table set val=val+100 WHERE CURRENT OF $cursth->{CursorName}");
    $updsth->execute;
    $db->commit;
    $db->Close();
    Thanks in advance
    PS: The table has one row and the intention is to update the row using where current of clause.
    Message was edited by:
    k.venkat

    Thanks Justin for your reply.
    I am aware of I dont need a cursor for updating single row..but from one of the applications (which uses ORACLE ODBC) i get this ODBC error "no rows updated" if I hit on save button twice (from the application)
    The ODBC trace shows "where current of" clause and in the database (ORACLE 9.2) shows "update tablename set ...where rowid = "
    Now I am trying to test the ODBC and trying to generate the same Statements (with where current of)
    and fyi: PERL/WIN32:ODBC supports where current of coding-style (source: http://www.codeproject.com/books/1578700671.asp ..search for 'where current of')
    The point is I dont want to manually grab the rowid and use it for update..Instead I want the ODBC write its own statement
    Thanks
    Venkat

  • For update & where current of in cursor

    Hi,
    Please explain any For Update with WHERE CURRENT OF clause in cursor.
    Diwakar

    Hi,
    I am getting meaning of FOR UPDATE CLAUSE but Right now i am not getting WHERE CURRENT OFF clause.
    Basically For Update clause in PL/SQL cursor used for locking the Row which is extracted by the query. But what is the use of WERE CURRENT OF Clause. When we use WERE CURRENT OF clause at that time cursor must should have FOR UPDATE CLAUSE in cursor declaration.
    Thank you Diwakar
    Here is link in documentation:
    http://download-uk.oracle.com/docs/cd/B14117_01/server
    .101/b10759/statements_10002.htm#i2126016
    Peter D.
    It's link to SELECT FOR UPDATE statement.
    Message was edited by:
    Peter D.

  • For Update Of &Where current of

    Can you please give answer anyone,What is main use of For update Clause and Where current of Clause?

    When you will want to lock a set of records even before you change them in your program. Oracle offers the FOR UPDATE clause of the SELECT statement to perform this locking.
    When you issue a SELECT...FOR UPDATE statement, the RDBMS automatically obtains exclusive row-level locks on all the rows identified by the SELECT statement, holding the records "for your changes only" as you move through the rows retrieved by the cursor. No one else will be able to change any of these records until you perform a ROLLBACK or a COMMIT.
    The Where Current Of statement allows you to update or delete the record that was last fetched by the cursor.

  • The Cursor's "For Update " and " Where Current of C1" Error in Form9i

    Hi,
    I use a cursor with for update statement. And after it, I update the table with "where current of", then it cause the forms hanged up. But In form50 of dp2k, I can run the form successfully.
    The following source code are written in a Key-Next-Item
    Please help me with the problem!!!!!
    declare
    v_cash date;
    v_entno varchar2(16);
    Cursor c1 is
    select proc_date,entno from loan_bank for update;
    begin
    open c1;
    loop
    fetch c1 into v_cash,v_entno;
    exit when c1%NOTFOUND;
    update loan_bank set proc_date=sysdate where current of c1;
    end loop;
    commit;
    close c1;
    show_alert_info('OK! Done to Proc Date');
    end;

    Hello there,
    I'm also facing the same problem...
    Have you found any solution or work-around yet?
    The code i'm using is the following:
    IS
    CURSOR cur_autonum
    IS
    SELECT an_nr + 1
    FROM autonum
    WHERE an_kode ='ADV'
    FOR UPDATE OF an_nr NOWAIT
    RECORD_NOT_FOUND EXCEPTION;
    RECORD_IS_LOCKED EXCEPTION;
    PRAGMA EXCEPTION_INIT(RECORD_IS_LOCKED,-54);
    BEGIN
    OPEN cur_autonum;
    FETCH cur_autonum INTO :ptperson.pe_nr;
    IF cur_autonum%FOUND
    THEN
    UPDATE autonum
    SET an_nr = :ptperson.pe_nr
    WHERE CURRENT OF cur_autonum;
    CLOSE cur_autonum;
    ELSE
         CLOSE cur_autonum;
         RAISE RECORD_NOT_FOUND;
    END IF;
    EXCEPTION
    WHEN RECORD_NOT_FOUND
    THEN
    :global.rc := fnc_alert(118);
    clear_record;
    previous_record;
    RAISE Form_Trigger_Failure;
    WHEN RECORD_IS_LOCKED
    THEN
    IF cur_autonum%ISOPEN
    THEN
    CLOSE cur_autonum;     
    END IF;
    :global.rc := fnc_alert(119);
    clear_record;
    previous_record;
    RAISE Form_Trigger_Failure;
    WHEN OTHERS
    THEN
    IF cur_autonum%ISOPEN
    THEN
    CLOSE cur_autonum;     
    END IF;
    RAISE;
    END;
    greetings,
    Emiel

  • For Update and Where Current Of -

    HI All,
    We have been using Select For Update statement with wait time (i.e in seconds) in various places inside our applications. This forces for locking those rows and we commit the work at the end of our work to ensure we release the locked rows to avoid deadlock in the application. However at times we face locks during heavy contention when running those cursors in the application.
    I have 2 questions here
    1) By using where current of do we stand to gain anything advantageous so that we gain out of it. Will it try to eliminate such row level locks said above.
    2) How to avoid locks occurring in the application while using Select For Update Statements
    Please share your thoughts and suggestions to overcome on this worrying/concerning topic.
    Thanks in advance

    ramarun wrote:
    HI All,
    We have been using Select For Update statement with wait time (i.e in seconds) in various places inside our applications. This forces for locking those rows and we commit the work at the end of our work to ensure we release the locked rows to avoid deadlock in the application. However at times we face locks during heavy contention when running those cursors in the application. FOR UPDATE exists to put locks on selected data so other processes cannot lock data between the time it is selected and processed. As you're finding there are disadvantages.
    1) By using where current of do we stand to gain anything advantageous so that we gain out of it. Will it try to eliminate such row level locks said above.WHERE CURRENT OF will save you typing when you do WHERE clauses. It should not affect locking at all
    2) How to avoid locks occurring in the application while using Select For Update Statements You don't avoid locks when using the FOR UPDATE clause because that is what its for. If you don't need to lock the data then do not use FOR UPDATE.
    Edited by: riedelme on Aug 11, 2010 5:34 AM
    Updated after sybrand's comments below. Technically using WHERE CURRENT OF shouldn't affect locking directly - rows will remain locked until the transaction is terminated. Referencing the data via the rowid will be more efficient and therefore shorten the time taken to process the transaction

  • Using sp.js how to query list items where current user is the author

    using javascript, want to query list items where the author is the current logged on user.
    how to construct a caml query for author and logged on user?
    http://msdn.microsoft.com/en-us/library/office/hh185007(v=office.14).aspx

    Hi,
    Thanks for your sharing.
    Jason
    Jason Guo
    TechNet Community Support

  • Report to find current settings of system in SOBJ

    Does a report exists with which I can find the current settings which aren´t transportable?

    Hi Damian,
    Use SE16 on table OBJH where "current Setting" or column CURSETTING = X to  display the objects that have current setting flag set.
    Thank You.
    Regards,
    Deepika

  • How can I modify one column of current and next record depending of some criteria?

    Having DDL
    CREATE TABLE #ServiceChange(
    [ID] [int] identity(1,1),
    [SHCOMP] [char](2) NOT NULL,
    [SHCRTD] [numeric](8, 0) NOT NULL,
    [SHCUST] [numeric](7, 0) NOT NULL,
    [SHDESC] [char](35) NOT NULL,
    [SHTYPE] [char](1) NOT NULL,
    [SHAMT] [numeric](9, 2) NOT NULL,
    [CBLNAM] [char](30) NOT NULL,
    [GROUPID] [char](2) NULL
    And original and desire data in below link
    https://www.dropbox.com/sh/bpapxquaae9aa13/AADnan31ZASublDjN7sa2Vvza
    I would like to know how can I modify one column of current and next record depending of some criteria using SQL2012?
    The criteria is:
    Type should always flow F->T
    if current abs(amount)> next abs(amount) then groupid = 'PD'
    if current abs(amount)< next abs(amount) then groupid = 'PI'
    there is no case when those amounts will be equals
    where current(custid) = next(custid) and current(service) = next(service) and groupid is null
    Any help will be really apreciated.
    Thank you

    I tried that and got this error
    'LAG' is not a recognized built-in function name.
    You said you were using SQL 2012, but apparently you are not. The LAG function was added in SQL 2012. This solution works on SQL 2005 and SQL 2008:
    ; WITH numbering AS (
       SELECT groupid,
              rowno = row_number()  OVER (PARTITION BY custid, service ORDER BY date, id)
       FROM   #ServiceChange
    ), CTE AS (
       SELECT a.groupid,
              CASE WHEN abs(a.amount) < abs(b.amount) THEN 'PD'
                   WHEN abs(a.amount) > abs(b.amount) THEN 'PI'
              END AS newgroupid
       FROM  numbering a
       JOIN  numbering b ON b.custid  = a.custid
                        AND b.service = a.service
                        AND b.rowno   = a.rowno - 1
    UPDATE CTE
    SET   groupid = newgroupid
    Erland Sommarskog, SQL Server MVP, [email protected]

  • UPDATE CURRENT Problem

    I am using Oracle8i Release 8.1.6.0.0, and now I encounter an
    error when running the following PL/SQL Block:
    1 declare
    2 cursor c1 is
    3 (select k1, f1 from geotab1)
    4 for update of f1;
    5 cursor c2 (key_k1 in geotab1.k1%type) is
    6 (select f2 from geotab2
    7 where k1 = key_k1);
    8 begin
    9 for rec in c1 loop
    10 open c2 (rec.k1);
    11 fetch c2 into rec.f1;
    12 if c2%found then
    13 update geotab1
    14 set f1 = rec.f1
    15 where current of c1;
    16 end if;
    17 close c2;
    18 end loop;
    19* end;
    update geotab1
    ERROR at line 13:
    ORA-06550: line 13, column 10:
    PLS-00801: internal error [22602]
    ORA-06550: line 13, column 10:
    PL/SQL: SQL Statement ignored
    Note that the field k1 is the primary key of geotab1, and k2 is
    the primary key of geotab2. When I replace the "where current of
    c1" with "where k1 = rec.k1", the error is fixed and the program
    block update geotab1 correctly.
    I suppose the "where current of" clause works, but I have no
    idea on the meaning of the internal error [22602]. What's going
    wrong? Should I patch the Oracle Server?

    Thank you for your advice. Unfortunately, the problem still
    persists when running the first block of PL/SQL you suggested:
    1 DECLARE
    2 CURSOR c1 is
    3 (SELECT k1, f1
    4 FROM geotab1)
    5 FOR UPDATE OF f1;
    6 var_f2 geotab2.f2%type;
    7 BEGIN
    8 FOR rec IN c1 LOOP
    9 BEGIN
    10 SELECT f2 INTO var_f2
    11 FROM geotab2
    12 WHERE k1 = rec.k1;
    13 UPDATE geotab1
    14 SET f1 = var_f2
    15 WHERE CURRENT OF c1;
    16 EXCEPTION
    17 WHEN NO_DATA_FOUND THEN
    18 NULL;
    19 END;
    20 END LOOP;
    21* END;
    DECLARE
    ERROR at line 1:
    ORA-06550: line 13, column 10:
    PLS-00801: internal error [22602]
    ORA-06550: line 13, column 10:
    PL/SQL: SQL Statement ignored
    I've fixed some syntax errors and remove the commit statement
    inside the codes. It seems not the problem of cursor variable.
    The second block of PL/SQL you suggested seems to be a better
    solution, and I should have use this logic before. Instead of
    using the exception NO_DATA_FOUND, I will insert "IF SQL%
    NOTFOUND THEN ..." after the UPDATE statement if I want to trap
    the condition. (NO_DATA_FOUND was not raised when no record was
    updated.)
    By the way, thank you very much for your advice.

  • How to get the directory name where the class resides

    I have following directory structure.
    c:\one\two\three\four\five\Test.java
    package name for Test.java is four.five
    When I run, four.five.Test, I want to get the compelte path name where currently the Test.class is running i.e. "c:\one\two\three\four\five\"
    so that if I move four.five.Test.java into some different directory structure, I should always get the complete path name.
    Thanks In Advance
    Sachin

    package x.y;
    import java.io.File;
    public class Test {
        public static void main(String[] args) {
            System.out.println(new File(Test.class.getResource("").getFile()).getAbsolutePath());
    }

  • Selecting Invoice (OINV) records from the current financial year

    Hi Everyone,
    I would like to select Invoices (OINV) from the current Financial Year. I am located in Australia and our financial year is measured from the 1st of July to the 30th of June.
    Here is a pseudo - code sample -
    SELECT T1.DocEntry, T1.DocNum, T1.DocDate
    FROM AU.dbo.OINV T1
    WHERE "CURRENT FINANCIAL YEAR"
    Notice above that I would like to replace "CURRENT FINANCIAL YEAR" with an SQL code snippet that selects all dates from the beginning of the financial year (1/07/xx) to the current date.
    Any help here will be greatly appreciated.
    Kind Regards,
    David

    Hi Everyone,
    Here is a code snippet that permits returning only values from the current financial year -
    DECLARE @day nvarchar(2) = DAY(GETDATE())
    DECLARE @currentMonthAndDay INT = CAST(CAST(MONTH(GETDATE()) as nvarchar(2)) + (REPLICATE('0', 2 - LEN(@day)) + @day) as int)
    DECLARE @StartOfFinancialYear DATETIME
    SET @StartOfFinancialYear = CAST(YEAR(GETDATE()) - CASE WHEN @currentMonthAndDay<701 then 1 else 0 end as nvarchar(max)) + '0701'
    SELECT *
    FROM AU.dbo.OINV T0
    WHERE T0.DocDate >= @StartOfFinancialYear
    AND T0.DocDate < DATEADD(yy, 1, @StartOfFinancialYear)
    Many thanks to Faheem for providing the answer to returning only results from the current financial year, in this thread: http://social.msdn.microsoft.com/Forums/sqlserver/en-US/2edbe630-faca-4f94-a014-04f5a832f81d/returning-results-that-fall-within-the-current-financial-year?forum=transactsql
    Kind Regards,
    David

  • Current user overruled in integration server

    Hi,
    I have a proxy-PI-IDOC interface. The connectivity between SAP PI and the backend system where the IDOC will be sent to is established via a trusted RFC connection where 'current user' is marked. In most of the times the interface is working but in several times I got the error in SM58 'You are not authorized to logon to the system..'. The problem however is that for this action the wrong user is used (an user that indeed is not authorized). It looks that in the connection from the PI system to the backed system the current user is lost and overruled by an user of a former message which has nothing to do with this interface but runs at the same time.
    Has anyone faced the same problem and are there any solutions for this.
    kind regards
    Maarten

    Hi,
    I have a proxy-PI-IDOC interface. The connectivity between SAP PI and the backend system where the IDOC will be sent to is established via a trusted RFC connection where 'current user' is marked. In most of the times the interface is working but in several times I got the error in SM58 'You are not authorized to logon to the system..'. The problem however is that for this action the wrong user is used (an user that indeed is not authorized). It looks that in the connection from the PI system to the backed system the current user is lost and overruled by an user of a former message which has nothing to do with this interface but runs at the same time.
    Has anyone faced the same problem and are there any solutions for this.
    kind regards
    Maarten

  • Utilizing the cursor's current position in an action?

    I had hoped this would be an easy thing to achieve but I have yet to find a solution after searching for many hours. Basically I want to use the current position of the cursor as a variable in an action, rather than the exact XY coordinates as recorded during the making of the action. More specifically I want to bucket fill a particular part of the image based on where my mouse is at the time of executing the action.
    Any ideas? And with something this simple, would I even need to use a script? Any kind of help would be greatly appreciated!

    Hello there,
    I'm also facing the same problem...
    Have you found any solution or work-around yet?
    The code i'm using is the following:
    IS
    CURSOR cur_autonum
    IS
    SELECT an_nr + 1
    FROM autonum
    WHERE an_kode ='ADV'
    FOR UPDATE OF an_nr NOWAIT
    RECORD_NOT_FOUND EXCEPTION;
    RECORD_IS_LOCKED EXCEPTION;
    PRAGMA EXCEPTION_INIT(RECORD_IS_LOCKED,-54);
    BEGIN
    OPEN cur_autonum;
    FETCH cur_autonum INTO :ptperson.pe_nr;
    IF cur_autonum%FOUND
    THEN
    UPDATE autonum
    SET an_nr = :ptperson.pe_nr
    WHERE CURRENT OF cur_autonum;
    CLOSE cur_autonum;
    ELSE
         CLOSE cur_autonum;
         RAISE RECORD_NOT_FOUND;
    END IF;
    EXCEPTION
    WHEN RECORD_NOT_FOUND
    THEN
    :global.rc := fnc_alert(118);
    clear_record;
    previous_record;
    RAISE Form_Trigger_Failure;
    WHEN RECORD_IS_LOCKED
    THEN
    IF cur_autonum%ISOPEN
    THEN
    CLOSE cur_autonum;     
    END IF;
    :global.rc := fnc_alert(119);
    clear_record;
    previous_record;
    RAISE Form_Trigger_Failure;
    WHEN OTHERS
    THEN
    IF cur_autonum%ISOPEN
    THEN
    CLOSE cur_autonum;     
    END IF;
    RAISE;
    END;
    greetings,
    Emiel

  • How to populate current time

    I have a form where current time needs to be populated. The way to form is to work is that the user tabs to time and the current time is populated , then they tab to the next time field and the new current time is populated there
    so on and so forth. How is this possible?

    Here's a JavaScript function that does the trick.
    function getCurrentTime() {
    var oNow = new Date();
    return oNow.getHours() + ":" + oNow.getMinutes() + ":" + oNow.getSeconds();
    Jared Langdon
    www.jlangdon.ca

Maybe you are looking for

  • HELP! The itunes application could not be opened. An Unknown error occurred (13014).

    a day or so ago my macbook 13in crashed in the middle of use, took several minutes to then reboot and now seems to be working fine except itunes will not open. when i try to open it a dialog box appears with the following message: "The itunes applica

  • How can i access the methods if i only got the java class file?

    just like what the topic said...i would like to ask if i only got the class file of java without API documentation. how can i know what method is included ? thanks a lot. my email address is : [email protected]

  • Windows Server 2012 R2 Routing problem

    Hello everybody I have the following problem: Server with two NICS, one (IP 172.30.8.X) it's configure with a default gateway (172.30.8.1), the other one (IP 172.30.32.X) doesn't have a default gateway and has a static route to reach another network

  • Draw a line smoothed

    How can I draw a line smoothed with awt.graphics??? I use this class and not Java 2D because i need use it with I.E. without Java Plugin.

  • Viewing programs in SE80 is finished with damp

    Hallo, Colleagues! There is a some strange behavior of ABAP. When the damp appeared (damp - SYNTAX_ERROR) there is no way to look throught the program, all attempts in SE80 finished with this damp again. And this is with all the programs(I cant view