FOR UPDATE OF table.field

Why does the following not work
create table division (code varchar2(2) primary key, div_desc varchar2(20));
insert into division values ('01', 'Ninja assassins');
insert into division values ('02', 'Working for the man');
create table employees (tk number, first_name varchar2(10), last_name varchar2(10), code varchar2(2) references division(code));
insert into employees values (1, 'Chuck', 'Smith', '01');
insert into employees values (2, 'John',  'Smith', '02');
DECLARE
  CURSOR my_csr IS
    Select e.tk, e.first_name, e.last_name
    From employees e, division d
    Where e.code = d.code
      and e.code = '01'
      and e.last_name = 'Smith'
    For update;
    cnt_updated NUMBER;
BEGIN
  cnt_updated := 0;
  FOR my_row IN my_csr
  LOOP
    Update employees
    Set last_name = 'Forbes'
    Where current of my_csr;
    cnt_updated := cnt_updated + SQL%ROWCOUNT;
    dbms_output.put_line('You updated '||cnt_updated||' records');
  END LOOP;
END;but just adding to the "for update" clause allows for an update?
DECLARE
  CURSOR my_csr IS
    Select e.tk, e.first_name, e.last_name
    From employees e, division d
    Where e.code = d.code
      and e.code = '01'
      and e.last_name = 'Smith'
    For update *of e.tk*;We found this out recently, and fellow Developers are asking "Why?". Is there a documented reason, or is that just how it is?
Thanks,
--=Chuck

It is not about locking it is how oracle translate the "where current". it is a simple rowid.
did a little trace, and look what I got from 10046 trace file:
For the update without the "update of", look at the 0 at the cr in the plan,
Oracle already knows that this update will not do anything:
PARSING IN CURSOR #6 len=62 dep=1 uid=82 oct=6 lid=82 tim=88904356722 hv=1877266405 ad='1a9b0404' sqlid='5a5zpz5ry9mz5'
UPDATE EMPLOYEES_T SET LAST_NAME = 'Forbes' WHERE ROWID = :B1
END OF STMT
PARSE #6:c=0,e=258,p=0,cr=0,cu=0,mis=1,r=0,dep=1,og=1,tim=88904356717
BINDS #6:
Bind#0
  oacdty=208 mxl=3950(3950) mxlc=00 mal=00 scl=00 pre=00
  oacflg=00 fl2=206001 frm=00 csi=00 siz=3952 off=0
  kxsbbbfp=0c2ef090  bln=3950  avl=00  flg=05
EXEC #6:c=0,e=1108,p=0,cr=0,cu=0,mis=1,r=0,dep=1,og=1,tim=88904357955
STAT #6 id=1 cnt=0 pid=0 pos=1 obj=0 op='UPDATE  EMPLOYEES_T (cr=0 pr=0 pw=0 time=0 us)'
STAT #6 id=2 cnt=0 pid=1 pos=1 obj=74422 op='TABLE ACCESS BY USER ROWID EMPLOYEES_T (cr=0 pr=0 pw=0 time=0 us cost=1 size=29 card=1)'for the update with the "update of", look at the 1 at the cr in the plan:
PARSING IN CURSOR #6 len=62 dep=1 uid=82 oct=6 lid=82 tim=88913977309 hv=1877266405 ad='1a9b0404' sqlid='5a5zpz5ry9mz5'
UPDATE EMPLOYEES_T SET LAST_NAME = 'Forbes' WHERE ROWID = :B1
END OF STMT
PARSE #6:c=0,e=87,p=0,cr=0,cu=0,mis=0,r=0,dep=1,og=1,tim=88913977304
BINDS #6:
Bind#0
  oacdty=208 mxl=3950(3950) mxlc=00 mal=00 scl=00 pre=00
  oacflg=00 fl2=206001 frm=00 csi=00 siz=3952 off=0
  kxsbbbfp=09f3abfc  bln=3950  avl=13  flg=05
  value=
Dump of memory from 0x09F3ABFC to 0x09F3AC09
9F3ABF0                            22010001              [..."]
9F3AC00 000400B6 00780401 00000000           [......x.....]   
EXEC #6:c=0,e=379,p=0,cr=1,cu=1,mis=0,r=1,dep=1,og=1,tim=88913977802
STAT #6 id=1 cnt=1 pid=0 pos=1 obj=0 op='UPDATE  EMPLOYEES_T (cr=1 pr=0 pw=0 time=0 us)'
STAT #6 id=2 cnt=1 pid=1 pos=1 obj=74422 op='TABLE ACCESS BY USER ROWID EMPLOYEES_T (cr=1 pr=0 pw=0 time=0 us cost=1 size=29 card=1)'Also notice that in the update version with the "update of" we can see dump of memory.
There are some binds type that oracle won't show directly in the dump (e.g. timestamp, rowid, etc)
For future, more hex oriented readers here is the rowid from table:
SQL> select rowid from employees_t;
ROWID
AAASK2AAEAAAQR4AAAIf, somebody out there, can show me a way to read the memory dump back into the real rowid,
I will be very happy.
Amiel

Similar Messages

  • API for updating pay_people_groups table..

    Hi,
    Is there any API for updating pay_people_groups table. I know we can do it using hr_assignment_api.update_emp_asg_criteria but this API updates the assignement with the new pay_group_id. I want to know is there is any API which can only update the pay_people_groups and not the assignment.
    Regards,
    Shabana.

    Hi,
    Technically you want update values for people group. If you remember At the time of definition of people group you created value set and attached people group flex field.
    People group are created on the basis of combination of segments. So you have to update only values not people group.
    I doubt oracle provides API to update key flex field.
    You may get API to update values try out that option.
    Hope this helps.
    Sathish

  • XD02 transaction to change the customer data for updating KNA1 table?

    Hi all,
    How can we use XD02 transaction to change the customer data for updating KNA1 table?
    Give the steps.
    Thanks in advance
    rk

    Hi KR,
    Why don't u use BDC to run XD02.
    With Regards,
    Zafar Ali

  • Need Help in Field Symbol for Dynamically passing  table field value

    Hi All,
    In my internal table I am having data.
    I am dynamically forming table field name and substitute for the another table field name to pass DATA.
    but I am getting the Variable name insted of Value ie Data.
    I am using Field Symbol for this.
    data:
    Field-symbols <TS> type any.
    field1 type string.
    LOOP AT TABLEFIELDS INTO WA_TABLEFIELDS.
                READ TABLE  TEST  WITH KEY NAME = WA_TABLEFIELDS-FIELDNAME.
                IF SY-SUBRC = 0.
                  CONCATENATE 'WA_' WA_TABLEFIELDS-TABNAME '-' WA_TABLEFIELDS-FIELDNAME INTO  Field1.
                  Assign Field1 to <TS>.
                    ALL_VAL-VALUE = <TS>
    "After substituting the <TS>  into ALL_VAL-VALUE  field I need a DATA to be passed but the variable name is appending"*    
             APPEND ALL_VAL.
                ENDIF.
              ENDLOOP.
    kindly how to pass the value into the table.
    Thanks in advance.
    San

    Hi,
    pls assign a break point in
    CONCATENATE 'WA_' WA_TABLEFIELDS-TABNAME '-' WA_TABLEFIELDS-FIELDNAME INTO Field1.
    Assign Field1 to <TS>.
    ALL_VAL-VALUE = <TS>
       " Put a break point here and check for the value in <TS>.
    if <TS> contains value then create a work area for ALL_VAL AND PASS the Field-Symbol to that and then  append thw wa into the table...
    Hope this works out!!
    thanks

  • User exit/BADI for updating custom table in MB1B transaction-

    Dear All,
    When performing a material to material conversion in MB1B transaction for  batch managed materials,system is creating a new batch by copying the characteristics of issuing material/batch.The details of the new batch created are updated in standard batch tables(MCH1,MCHA,MCHA).
    The requirement is when the new batch is created,the batch details and characteristics has to be stamped in a custom table.
    Kindly suggest a user exit/BAIi available for updating the same in the custom table.
    Regards,
    Deepak

    Deepak, Exits for MB1B are
    MBCF0002            Customer function exit: Segment text in material doc. item
    MBCF0005            Material document item for goods receipt/issue slip
    MBCF0006            Customer function for WBS element
    MBCF0007            Customer function exit: Updating a reservation
    MBCF0009            Filling the storage location field
    MBCF0010            Customer exit: Create reservation BAPI_RESERVATION_CREATE1
    MBCF0011            Read from RESB and RKPF for print list in  MB26
    MB_CF001            Customer Function Exit in the Case of Updating a Mat. Doc.

  • I want to update standard table field (EKES-EINDT)? Not using BDC using FM.

    Hi all,
    I would like to seek for you help, to resolve a problem.
    I need to know how can i update the EINDT(date) field in the EKES table.
    Is there any Function Module or BAPI available for update EKES-EINDT ? 
    And my requirement is don't use BDC.
    Currently I am doing in following way
    LOOP AT I_DATA.
      UPDATE EKES SET EINDT = P_NEWDAT
      WHERE EBELN = I_DATA-EBELN
      AND EBELP = I_DATA-EBELP
      AND ETENS = I_DATA-ETENS.
    ENDLOOP.
    I know we should not update standard table directly. This will only update EKES it will not update other tables related with EKES-EINDT.
    Got my point?
    Please help me it's on high priority.

    EKES can be updated with function module
    ME_CONFIRMATION_UPDATE

  • Bapi for updation of table VBRP

    Hi,
    I have to Update the Field 'KONDM' in the table VBRP. Is there some BAPI available for updating VBRP or we can have to go with the direct Update to the table. I have to Update this field by a stand alone report program.
    Thanks and regards,
    Pankaj Bist.

    Might be use this Function module
      CALL FUNCTION 'RV_INVOICE_ITEM_MAINTAIN'
           EXPORTING
                VBRP_I = VBRP
           IMPORTING
                VBRP_E = VBRP
           TABLES
                XKOMFK = XKOMFK
                XTHEAD = XTHEAD
                XVBFS  = XVBFS
                XVBSS  = XVBSS
                XVBRK  = XVBRK
                XVBRP  = XVBRP
                XVBPA  = XVBPA
                XKOMV  = XKOMV.
    Matintain the value in the VBRP table & pass rest as is... u get the value using the FM RV_INVOICE_DOCUMENT_READ

  • Module pool - for updating Z table

    Moderator message: please using a more meaningful subject.  I've edited it for you this time.
    Hi i have a reuire ment like  this.
    i want to update Z table, by using report program.report is having selection screen ti select data from Z table and to disply in a screen like SM30, i am displying in table control using screen.and i am updating Z table.
    i want to display the selection screen data which ever i have given just above the table control which ever i am displaying now.
    can any body help me out pls.
    Regards
    naidu

    Hi palani thanks for reply.
    i tried in this way already but the problem is we dont know how many values user  will enter to define, suppose if user may enter 1000 entries in one selection field  or beyond that also.
    in this case again the problem.
    and one more thing suppose i ahve selection screen like this
    company code   parameter               mandatory
    sales org.          ranges
    division              ranges
    KUNNR               ranges
    if suppose user entered only mandatory value, and KUNNR we need to display only those two in output, but here in module pool by using screen table if we disable the screen two blank lines will come.
    ex
    cmpany code 0001
    KUNNR         from 1000 TO 2000.
    expected result for this is
    cmpany code 0001
    KUNNR         from 1000 TO 2000.
    i used scren-input for this but ididnt get,
    could you please help me in this.
    thanks and regards
    naidu

  • Performance manager sql action rule for updating metric table

    Hi, I need to update metric stop_date using a sql action rule (Performance Manager execute sql action rule). My problem is I can't update stop_date into the PM Repository Database. Sql action database connection is properly set, but when I set sql for executing update in table ci_probe and I schedule the rule the system doesn't seem to connect to Database (the rule run successfully, but the table ci_probe is not updated). I don't understand if the problem is database connection or wrong sql code.
    Can Anyone help me with suggestions or sql action rule samples?
    Thanks
    Luigi
    Edited by: Luigi Oliva on Jun 13, 2008 1:32 PM

    Hi It's working, Problem was in repeat_interval it's working now,
    Thanks,
    I changed
      repeat_interval          => 'FREQ=DAILY;BYSECOND=10',to
      repeat_interval          => 'FREQ=SECONDLY;BYSECOND=10',Thanks,
    Edited by: NSK2KSN on Jul 26, 2010 11:14 AM

  • How to write a procedure for update the table

    Hi all
    can any body please tell me how to write a procedure to update the table......
    I have a table with about 10,000 records...........Now I have add a new column and I want to add values for that like
    registration Code Creidits
    13213 BBA
    1232 MCS
    I had add the creidit now i want to update the table.........the new value want to get by SQL like
    Creidit = select creidit from othere_table...........
    Hope u can understand my problem
    Thanks in advance
    Regards
    Shayan
    [email protected]

    Please try the following --
    update Program_reg a
    set TotalCreidit = ( select tot_cr <Accroding to your logic>
                                from Program_reg b
                                where a.Registration = b.Registration
                                and    a.Enrollment = b.Enrollment
                                and    a.code = b.code
    where a.Registration in ( select distinct Registration
                                        from Program_reg );
    N.B.: Not Tested....
    Regards.
    Satyaki De.

  • DateFormat for updating the metadata field through RIDC

    Could you please tell me what will be the valid date time format for updating metadata field value through RIDC.?
    I am using ADF technology to connect with webcenter UCM and using all services to check-in,update, search generic screens using UCM services. I am able to update other text type metadata field through ADF screen BUT when i update date field then i am getting date parsing error..
    xSubmitDate DATE type in UCM.
    xSubmitDate value = 05/08/2013 05:36 PM
    oracle.stellent.ridc.protocol.ServiceException: Unable to update the content item information for '0804'. The field 'xSubmitDate' does not contain a valid date. Unable to parse date '05/08/2013 05:36 PM'.
    Thanks in Advance.

    This blog post I wrote may be of some help: http://www.redstonecontentsolutions.com/5/post/2011/10/parse-date-usingridc.html
    Jonathan
    http://jonathanhult.com

  • BAPI for updating Evaluation Group1 field in Asset Master

    Hi,
    The business requirement is to Update the Assets master fields with the current location of the Tools with respect to movement of the material only to be used for assets.
    To keep a track for tools being moved to vendor location or internal company. To know the exact liabilities to the company in terms of Capitals being moved to the vendor or company location.
    For this the movement type of the material will define weather the material is within the Campus or is with the Vendor & update the field  Evaluation Group 1 (ANLA-ORD41)
    Can you please help with which BAPI should be used for updating the evaluation group?
    Thanks

    Hi Anupam
    Would appreciate, if you are not arrogant, while  posting your queries to this Forum.
    You can use the Function Module
    ASSET_MASTERRECORD_MAINTENANCE
    Regards
    Sanil

  • Add a Select List to a Report, for Updating a table.

    I am working on Apex 3.0. I had to allow the Report could update a table. I added two checkbox to the report, and now I should add a Select List. I've tried a lot of ways but I don't know how can I pass the value selected, related to the ID of the row. I've tried with a JavaScript but I couldn't. A process should update the row on the DB when the user change the value on the select list. There is a save button that perform the process. How I could pass the ID of the row and the value to a PL/SQL process?
    Many Thanks for your suggestions.
    SELECT PFA.FOCUS_AREA_ID
    ,FOCUS_AREA_NAME,     
    apex_item.checkbox(1, FA.FOCUS_AREA_ID, DECODE(PFA.FOCUS_AREA_ID, null, ' ','checked="checked" ') ||
    'id="chk'||rownum||'"'|| ' onclick="checking(this)" ') as Focus_AREA_CHK,
    APEX_ITEM.SELECT_LIST(
    *5,*
    PFA.FOCUS_TYPE,
    *'DIS;DIS,ENG;ENG,EXP;EXP,TGT;TGT',*
    *'id="sl_'||FA.FOCUS_AREA_ID||' " ',*
    *'YES',*
    NULL,
    *'-Select-',*
    *DECODE(PFA.FOCUS_AREA_ID, null, 'disabled="disabled" ','' ) || ' --onchange="selectedElement(this)" ',*
    *'NO'*
    *)* "Type"
    FROM PROGRAM_FOCUS_AREAS PFA,
    FOCUS_AREAS FA
    WHERE
    FA.FOCUS_AREA_ID = PFA.FOCUS_AREA_ID(+)
    AND :P151_PROGRAM_ID = PFA.VS_PROGRAM_ID(+)

    **Deleted**
    Edited by: user4498053 on Dec 27, 2011 11:24 AM

  • Resource configuration for updating multiple tables

    Hi all,
    My aim is to update multiple tables in Sun Identity Manager
    I would like to know what is the resource to be configured for this
    Could any one help me in solving this issue
    Thanks in advance,
    Shalini

    I have used the Scripted JBDC resource as follows;
    go to Resources > Configure Types and select Scripted JDBC > Save
    at Resources, select resource Type Actions > New Resource
    select Scripted JDBC from the drop down, this should start the wizard
    the wizard will guide you with lots of questions.
    The one problem we had is in the Action Scripts (second wizard page). we found the example scripts
    at the webserver root /idm/sample/ScriptedJdbc/SimpleTable/beanshell
    the above scripts had to be modified to the SQL required for the application, but it worked well with the example databases and codes that it is easily understood.
    there are several examples of different table types here... there are lots of options, see the README iles for each type
    hope this helps;
    TG

  • Import excel for update of table

    Hello
    I'd like to import data from an excel spreadsheet or CSV file. Is there a simple way to update the table with this data?
    Can import handle one spreadsheet containing data from 2 tables of which one is to be updated.
    Eg. column 2 in rows 1 to 4 contain the foreign key values. The remaining rows contain the data to be uploaded to the table (UPDATE no INSERT)
    Thanks
    Cindy

    Import is a utility that imports files in Oracle's proprietary binary dump format. The tool you would be looking at for loading a CSV file is SQL*Loader.
    SQL*Loader can handle logical records that span lines, but it does not allow you to update a subset of the existing data in a table. You could load the data into a staging table and UPDATE the master from the staging table, however.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

Maybe you are looking for