Update using rowID - 9i

hi everyone,
i´m updating a table that has more then ten miilion records, but don´t have PK... and this is very time consuming...
Anyone have any idea how to improve this?
Tks
update tablex
set a = :a
,b= :b
where rowiId = :rowId
above the trace:
UPDATE CRH_CONTRACHEQUE SET FL_MIGRADO = 'S' ,CDHISTORICORUBRICAVINCULO = :B2
WHERE
ROWID = :B1
UPDATE CRH_CONTRACHEQUE SET FL_MIGRADO = 'S' ,CDHISTORICORUBRICAVINCULO = :B2
WHERE
ROWID = :B1
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 994 11.12 32.70 784 1505862 1670975 994
Fetch 0 0.00 0.00 0 0 0 0
total 995 11.12 32.70 784 1505862 1670975 994

You can try with Merge
like
merge into CRH_CONTRACHEQUE a
using (select b2,b1 row_id from your source_table  )b--(assuming rowid)
on (a.rowid=b.row_id)
when matched then update
SET FL_MIGRADO = 'S' ,
and CDHISTORICORUBRICAVINCULO = b.B2

Similar Messages

  • Updating a row of a table using rowid

    Hi folks,
    I am trying to update some rows in a table using rowid of the corresponding rows.Sometimes this updates wrong rows. This is because ORACLE by itself makes some statistics on the particular table using "Analyze table..." statement and it changes the order of the rowids. But if I delete the statistics,the updation works fine. Is there any way to update the correct rows and also to keep the statistics created by ORACLE? P.s: I am using ORACLE thin Driver to connect to Oracle 8.1.6
    Thanks,
    Karthi.

    First make it clear: analyze table command never changes ROWIDs. Actually, the ROWID of a row never changes untill it's deleted from its table. So make sure if you are using the correct ROWID.
    Thnx

  • Using rowid in ref cursor

    Hi,
    I want to use rowid for updating the rows in the ref cursor. My code looks like below:
    DECLARE
    emp_refcursor SYS_REFCURSOR;
    emp_rec employee%ROWTYPE;
    l_run_id NUMBER;
    lv_sql_stmt VARCHAR2(4000) := 'SELECT a.* FROM employee a where a.run_id = :l_run_id ';
    OPEN emp_refcursor FOR lv_sql_stmt
    USING l_run_id;
    LOOP
    FETCH emp_refcursor
    INTO emp_rec;
    EXIT WHEN emp_refcursor%NOTFOUND;
    Here in lv_sql_stmt I want to include the rowid also so that I can use the update statement with the rowid. I cant directly add the rowid in the query as I am fetching the records in emp_rec which is of the rowtype of table EMPLOYEE.
    I want to use rowid for making the fetching of records faster.
    Please suggest e some ways to implement it.
    Thanks.
    Edited by: user12841217 on Mar 23, 2010 12:12 AM

    user12841217 wrote:
    Hi,
    I want to use rowid for updating the rows in the ref cursor.There are no rows in a ref cursor. Read the following:
    PL/SQL 101 : Understanding Ref Cursors :-
    PL/SQL 101 : Understanding Ref Cursors
    My code looks like below:
    DECLARE
    emp_refcursor SYS_REFCURSOR;
    emp_rec employee%ROWTYPE;
    l_run_id NUMBER;
    lv_sql_stmt VARCHAR2(4000) := 'SELECT a.* FROM employee a where a.run_id = :l_run_id ';
    OPEN emp_refcursor FOR lv_sql_stmt
    USING l_run_id;
    LOOP
    FETCH emp_refcursor
    INTO emp_rec;
    EXIT WHEN emp_refcursor%NOTFOUND;
    Here in lv_sql_stmt I want to include the rowid also so that I can use the update statement with the rowid. I cant directly add the rowid in the query as I am fetching the records in emp_rec which is of the rowtype of table EMPLOYEE.
    I want to use rowid for making the fetching of records faster.
    Please suggest e some ways to implement it. This sounds like half of the requirement. If you're already fetching the rows using your ref cursor, then why would you need the rowid to fetch them again?
    If you really need to include rowid in your query then you're going to have to fetch into a known defined structure rather than employee%ROWTYPE. This is what we call in the business... "design", which is usually based on "requirements". Know your requirements and implement a suitable design accordingly. A good design would seldom be selecting "*" within any query, as a good design would actually know what data is expected to be fetched.

  • Using rowid in a query

    We are using a function that takes the rowid of a table as an input parameter. Is there a way to access the rowid element of a table in OWB. I cannot see a way to do it within the tool.
    Thanks you,
    Matt

    We are using OWB 10.1.xxx and I **still** don't see
    ROWID! ROWID is the most efficient way of doing
    updates if it is available Ummm. ROWID is a physical way of doing things, and star schema dessign and implementation is a pretty logical approach. Could I ask why you are using ROWID, please? After all, the star schema depends on synthetic keys between the Facts and the Dimensions. I am at a loss to understand where ROWID fits into this. I personally have never seen a situation where ROWID could even have been used.
    Could you help me, please?
    Regards,
    Donna

  • How to split the query using rowid

    can anybody pls tell me logic to spliting the sql query by using rowid through dba_extent...

    Using Parallel Execution will help if it is the DB that is the bottleneck, but if on the other hand it is your client program that is the bottleneck (and the DB is supplying the data as fast as it can) then splitting the query into rowid ranges and having multiple extract clients will have benefit.
    1) Each extract process should read DBA_EXTENTS for the given object and select the extents it should process (Ideally 1 extract process per Data File).
    2) Use the DBMS_ROWID.ROWID_CREATE to build low and high rowid ranges based on the BLOCK_ID and BLOCKS from DBA_EXTENTS. Note you will also have to look up the DATA_OBJECT_ID for the Table in question.
    Note. Because we won't know the Row Number of the last row in the last block, use the first row in the first block after the last block and then use <.
    3) Add the ROWID hint to your query.
    4) Use >= "Low Rowid" < "High Rowid" (Note. use of < rather than <=)
    This method is only safe when the table in question is not being updated, as each extract process will be running its own read consistent view, and so there is a danger that transaction updating 2 rows could have only half of the update extracted (if 1 row was in 1 extent after it had been extracted and another row was in another extent before it was extracted).
    Only 1 rowid range can be passed to the query at a time (you can supply more, but a ROWID access will no longer be performed, it will simply to a FTS).

  • How to use Rowid in Cursor

    Hi all,
    Suppose i am updating some Rows in a cursor.
    Can u plz let me know the Syntax of Using ROWID in Cursor with a simple example.plzz
    i am trying to execute the follwing code but it si throwing error.Here i am trying to update salaries of employees who belong tO IT Department and whose salary is <5000
    Declare
    Cursor inc_salary is
    Select e.employee_id,e.salary,e.department_id,d.department_id DEPART
    from employees e,departments d
    where e.department_id=d.department_id
    and d.department_id='IT'
    and e.salary<5000 FOR UPDATE OF SALARY;
    Begin
    For inc_record in inc_salary
    Loop
    DBMS_OUTPUT.PUT_LINE('Employee Id is '||inc_record.employee_id);
    DBMS_OUTPUT.PUT_LINE('Original Salary is '||inc_record.salary);
    DBMS_OUTPUT.PUT_LINE('Department No in Employees Table is '||inc_record.department_id);
    DBMS_OUTPUT.PUT_LINE('Department No in Departments Table is '||inc_record.DEPART);
    End Loop;
    DBMS_OUTPUT.PUT_LINE('Lets Now increase the Salary of Employees');
    DBMS_OUTPUT.PUT_LINE('********************************');
    For inc_record in inc_salary
    Loop
    Update employees
    Set Salary=5000
    where Rowid=inc_salary.rowid;
    End Loop;
    End;
    Edited by: user12920808 on Aug 19, 2012 4:39 AM

    You update within
    For inc_record in inc_salarywhere inc_salary is a cursor and inc_record is a record where rows inc_salary are fetched into. While in update statement you are referencing cursor.column instead or record. column. You need to change:
    where Rowid=inc_salary.rowid;to
    where Rowid=inc_record.rowid;However, cursor inc_salary doesn't include employees.rowid, so you need to add it. And it should be department_name = 'IT', not department_id:
    Declare
    Cursor inc_salary is
    Select e.employee_id,e.salary,e.department_id,d.department_id DEPART,e.rowid e_rowid
    from employees e,departments d
    where e.department_id=d.department_id
    and d.department_name='IT'
    and e.salary<5000 FOR UPDATE OF SALARY;
    Begin
    For inc_record in inc_salary
    Loop
    DBMS_OUTPUT.PUT_LINE('Employee Id is '||inc_record.employee_id);
    DBMS_OUTPUT.PUT_LINE('Original Salary is '||inc_record.salary);
    DBMS_OUTPUT.PUT_LINE('Department No in Employees Table is '||inc_record.department_id);
    DBMS_OUTPUT.PUT_LINE('Department No in Departments Table is '||inc_record.DEPART);
    End Loop;
    DBMS_OUTPUT.PUT_LINE('Lets Now increase the Salary of Employees');
    DBMS_OUTPUT.PUT_LINE('********************************');
    For inc_record in inc_salary
    Loop
    Update employees
    Set Salary=5000
    where Rowid=inc_record.e_rowid;
    End Loop;
    End;
    Employee Id is 105
    Original Salary is 4800
    Department No in Employees Table is 60
    Department No in Departments Table is 60
    Employee Id is 106
    Original Salary is 4800
    Department No in Employees Table is 60
    Department No in Departments Table is 60
    Lets Now increase the Salary of Employees
    PL/SQL procedure successfully completed.
    SQL> And why do you have two loops instead of one. All you need is:
    SQL> Declare
      2  Cursor inc_salary is
      3  Select e.employee_id,e.salary,e.department_id,d.department_id DEPART,e.rowid e_rowid
      4  from employees e,departments d
      5  where e.department_id=d.department_id
      6  and d.department_name='IT'
      7  and e.salary<5000 FOR UPDATE OF SALARY;
      8  Begin
      9  For inc_record in inc_salary
    10  Loop
    11  DBMS_OUTPUT.PUT_LINE('Employee Id is '||inc_record.employee_id);
    12  DBMS_OUTPUT.PUT_LINE('Original Salary is '||inc_record.salary);
    13  DBMS_OUTPUT.PUT_LINE('Department No in Employees Table is '||inc_record.department_id);
    14  DBMS_OUTPUT.PUT_LINE('Department No in Departments Table is '||inc_record.DEPART);
    15  Update employees
    16  Set Salary=5000
    17  where Rowid=inc_record.e_rowid;
    18  End Loop;
    19  End;
    20  /
    Employee Id is 105
    Original Salary is 4800
    Department No in Employees Table is 60
    Department No in Departments Table is 60
    Employee Id is 106
    Original Salary is 4800
    Department No in Employees Table is 60
    Department No in Departments Table is 60
    PL/SQL procedure successfully completed.
    SQL> SY.

  • If you are attempting to update using a Mac or PC with which you do not normally sync

    what happens when "If you are attempting to update using a Mac or PC with which you do not normally sync", & they say in step 2 or 3 in order not to loose your stuff "If you are updating your iOS device on a computer with which you do not normally sync , or if you disconnect your device before the sync process is complete, you may notice that some media content that was previously on your device is no longer there. You can restore this content by syncing with the Mac or PC with which you normally sync."
    now what if the pc that was originally used to sync my ipod , has corrupt or  bad systems files that are causing it from working correctly...? when i plug it in to the o.g. operating sysytems (win xp) it doesnt ever recognize or discover the ipod through itunes.  the pc will pop up the "cameras been plugged in, what would you like to do...?" but nothing thru itunes.  now if i reboot & run the windows 7 operating system w/itunes that has backed my ipod before & synced a few times as well, but not the o.g. op system used from the beginning (the very initial set up done on the ipod) it works fine, but DOES give me the warning "updating to 5.0 willdelete some of your apps & media, including ...  ....will only preserve contacts, calenders," ....etc.
    MY HUGE CONCERN IS if i do hit update & go through w/it, & not having been able to sync it to the one normally used to sync my ipod, will that back up i made be able to restore my game seetings, GAME SAVES, & data achievement type information....?
    please, i'm very hesitant to go through w/it, so if you can please help me out here & let me know asap.....i canimagine you're all busy busy, so  i thank you for your time here w/this
    thank you
    mike z
    [email protected]

    Not that hard. One the computer you are using do the following:
    - Transfer iTunes purchases.
    iTunes Store: Transferring purchases from your iOS device or iPod to a computer
    - Transfer other music using a third-party program like one of those discussed here.
    Copy music
    - If you have synced photos you need a paid program like TouchCopy or PhoneView
    - When all the media in on the computer, connect the iPod to the computer and make a backup by right clicking on the iPod under Devices in iTunes and select Back Up
    - Restore the iPod from that backup.
    That computer is now your syncing computer. Note that the iPod backup that iTunes makes does not included synced media like apps or music.

  • ORA-12032: cannot use rowid column

    Hi,
    on 8.1.7 I have the following error :
    ORA-12032: cannot use rowid column from materialized view log on "string"."string"
    The solution is :
    Action: A complete refresh is required before the next fast refresh. Add ROWID columns to the materialized view log, if required.
    How can I do a complete refresh before the next fast refresh or Add ROWID columns ? How to know if Add ROWID columns is required ?
    Thank you.
    PS :
    my script is :
    START WITH TO_DATE('06-jul-2010 17:57:48','dd-mon-yyyy hh24:mi:ss')
    NEXT SYSDATE+1/24

    user522961 wrote:
    Hi,
    on 8.1.7 I have the following error :
    ORA-12032: cannot use rowid column from materialized view log on "string"."string"
    The solution is :
    Action: A complete refresh is required before the next fast refresh. Add ROWID columns to the materialized view log, if required.
    How can I do a complete refresh before the next fast refresh or Add ROWID columns ? How to know if Add ROWID columns is required ?
    Thank you.run above
    EXECUTE DBMS_MVIEW.REFRESH('MV_NAME','C');

  • Using ROWID in the WHERE clause of a SELECT statement

    hi all,
    my team is trying to select a value from a table using the rowid as the selection criterion
    e.g. select column_name from table_name where rowid > 'AAA112BBBCCC12A'
    this query does not appear to return accurate results e.g. it return rows instead of two. my questions are:
    1. is this a legitimate approach?
    2. should we convert the row id to varchar2? if so how should this be done?
    thanks!

    SQL> select rowid,ename
      2  from emp;
    ROWID              ENAME
    AAAs8KAA+AAAVXCAAA KING
    AAAs8KAA+AAAVXCAAB BLAKE
    AAAs8KAA+AAAVXCAAC CLARK
    AAAs8KAA+AAAVXCAAD JONES
    AAAs8KAA+AAAVXCAAE SCOTT
    AAAs8KAA+AAAVXCAAF FORD
    AAAs8KAA+AAAVXCAAG SMITH
    AAAs8KAA+AAAVXCAAH ALLEN
    AAAs8KAA+AAAVXCAAI WARD
    AAAs8KAA+AAAVXCAAJ MARTIN
    AAAs8KAA+AAAVXCAAK TURNER
    AAAs8KAA+AAAVXCAAL ADAMS
    AAAs8KAA+AAAVXCAAM JAMES
    AAAs8KAA+AAAVXCAAN MILLER
    AAAs8KAA+AAAVXCAAO erwer
    15 rows selected.
    SQL> select ename from emp where rowid = 'AAAs8KAA+AAAVXCAAH';
    ENAME
    ALLEN
    SQL> select ename from emp where rowid > 'AAAs8KAA+AAAVXCAAH';
    ENAME
    WARD
    MARTIN
    TURNER
    ADAMS
    JAMES
    MILLER
    erwer
    7 rows selected.1) using rowid to access a record is the quickest way so it is legitimate
    however using > has no real purpose as you point out you cannot get any meaningful results returned.
    2) No real need to convert however beware storing values in tables as Oracle does not guarantee to preserve the format in different versions so upgrading from 9i to 10g would invalidate your data.

  • Error while deleting Records using ROWID

    Hi all
    I have a small PL/SQL Block which accepts the Table Name as the User Input and
    deletes duplicate records from that table using ROWID.
    SET SERVEROUTPUT ON
    SET VERIFY OFF
    PROMPT Script to Delete Duplicate Records from a Table using ROWID
    ACCEPT TAB_NAME PROMPT 'Enter the Table Name : '
    DECLARE
    v_tab_name VARCHAR2(50):='&TAB_NAME';
    BEGIN
    EXECUTE IMMEDIATE 'DELETE FROM v_tab_name AA WHERE AA.ROWID <> (SELECT MIN(B.ROWID) FROM v_tab_name B WHERE AA.ID=B.ID)';
    DBMS_OUTPUT.PUT_LINE('Duplicate Records Deleted');
    END;
    When i execute this query it errors out saying table or view does not exist.
    Anybody's help is kindly appreciated.
    Regards
    Nakul.V

    Dear Nakul.V!
    Please change your execute immediate statement as follows:
    EXECUTE IMMEDIATE 'DELETE FROM ' || v_tab_name || ' AA
                       WHERE AA.ROWID IN (SELECT MIN(B.ROWID)
                                          FROM' || v_tab_name || ' B
                                          WHERE AA.ID=B.ID)';Yours sincerely
    Florian W.

  • My husband bought an iPad 2.  I have a Mac.  ITunes is in my name but I have turned sharing on.  When we updated to OS5 we lost all the free apps that he downloaded in his user name.  Is there no way to update using my iTunes without losing his software.

    My husband bought an iPad 2.  I have a Mac.  ITunes is in my name but I have turned sharing on.  When we updated to OS5 we lost all the free apps that he downloaded in his user name.  Is there no way to update using my iTunes without losing his software.  He is frustrated using the iPad because he never knows whether to use his user name or my user name.

    Apps are only tied to one account... You can set up two iTunes accounts on your computer, however, and let his iPad sync to his account. If he has never backed up his apps to a computer, however, he will have to redownload all the apps. Afterwards, he can backup to iCloud instead of your computer.
    http://support.apple.com/kb/ht1495

  • How can I script Adobe Reader updates using vbScript, PowerShell or C#?

    I would like to script Adobe Reader updates using vbScript, PowerShell or C#, are there any Adobe API calls I use to do this.  There are several different version that I support and auto update is not an option. I do updates at a specific time of the month. I would like to write a script that would download and install the update for the currently installed version of Adobe Reader (32 or 64 bit) for the version of the OS (32 or 64bit). I can detect the OS version and the Adobe version.  I can download updates but I do not want to hard code anything

    Sabian is correct.
    Most admins download the updates from the ftp site and push via AIP, GPO, SCCM, or some other method whenever it makes sense for them.
    Ben

  • Document Flow not updated using BAPI_GOODSMVT_CREATE

    Hi Experts,
    I am using BAPI_GOODSMVT_CREATE for doing PGR of an inbound delivery.
    Material Document(mblnr) is getting populated but Document Flow of that inbound delivery is not getting updated.Its status is Open.
    Can anyone knows how Document Flow can be updated using BAPI_GOODSMVT_CREATE??
    Regards,
    Puja.

    Hello Puja,
    Goto transaction SPRO, Go to Logistics Execution - Shipping - Basic shipping Functions - Configure Clobal Shipping Data, In this put a tick on Document Flow Update.
    Also refer to the below OSS note.
    http://service.sap.com/sap/support/notes/199703
    Regards,
    Thanga

  • Insert & Update using Writeback in a single Report

    Hi,
    Here is requirement:
    In the single report where the user has to do the Insert & update using the writeback functionality.
    below is the XMl:
    <?xml version="1.0" encoding="utf-8" ?>
    <WebMessageTables xmlns:sawm="com.siebel.analytics.web/message/v1">
    <WebMessageTable lang="en-us" system="WriteBack" table="Messages">
    <WebMessage name="SUBMITBUTTON">
    <XML>
    <writeBack connectionPool="CSDK">
    <insert>INSERT INTO HSCRTARGETLOOKUP(SLA_TYPE,TARGET_AVAILABILITY,TARGET_MTTR) VALUES ('@{c0}', @{c1}, @{c2})</insert>
    <update>UPDATE HSCRTARGETLOOKUP SET TARGET_AVAILABILITY = @{c1}, TARGET_MTTR = @{c2} WHERE SLA_TYPE = '@{c0}'</update>
    </writeBack>
    </XML>
    </WebMessage>
    </WebMessageTable>
    </WebMessageTables>
    Can you please let us know whether both insert & update will work at the same time using a single report.
    Thanks in Advance
    Siva

    Hi,
    Insert & update is working with the Single xml file:
    here it is how i have done:
    in the 1st criteria i have taken three columns and made union with the 3 dummy columns.
    in the 1st dummy column: CASE WHEN 1= 0 THEN HSCRTARGETLOOKUP.SLA_TYPE ELSE NULL END
    2nd dummy column: CAST('' AS INT)
    3rd dummy column: CAST('' AS INT)
    below is the single XML file which is working for both insert & update
    <?xml version="1.0" encoding="utf-8" ?>
    <WebMessageTables xmlns:sawm="com.siebel.analytics.web/message/v1">
    <WebMessageTable lang="en-us" system="WriteBack" table="Messages">
    <WebMessage name="STATES">
    <XML>
    <writeBack connectionPool="XXXX">
    <insert>INSERT INTO HSCRTARGETLOOKUP(SLA_TYPE,TARGET_AVAILABILITY,TARGET_MTTR) VALUES ('@{c0}', @{c1}, @{c2})</insert>
    <update></update>
    <update>UPDATE HSCRTARGETLOOKUP SET TARGET_AVAILABILITY = @{c1}, TARGET_MTTR = @{c2} WHERE SLA_TYPE = '@{c0}'</update>
    </writeBack>
    </XML>
    </WebMessage>
    </WebMessageTable>
    </WebMessageTables>
    Hope it works for you also.

  • Deletion of duplicates in the table with out using rowid

    How can I delete duplicates in the table with out using ROWID .

    hi
    sleect count(coulmnname),columnname from table
    group by columnname
    having count(columnname) > 1;
    find the primary key of the table
    apply the below query
    delete from table
    where (primary key,repeated column name )
    not in
    ( select min(primary key), repeated column
    from employee group by repeated column );
    use this in the primary key column use empid ,,,the repated column is ename
    empid ename
    1 sankar
    2 sankar
    try this one

Maybe you are looking for

  • IMac, mini-DVI to HDMI connection stopped working

    Hi, I recently switched from my good old white plastic iMac (late 2006, 20", Lion, 10.7.5 ) to another, slightly newer alu-body iMac (mid 2007, 20", Mountain Lion, 10.8.3). As before I used a Samsung SyncMaster as "desktop extension" connected via mi

  • How to set the size of my panels?

    I have 4 JPanels inside of a JFrame. I am using a GridLayout with 1 column and 4 lines. My problem is that all panels have the same size. I want to modify the size of each panel as I want. How can I do that? Message was edited by: aditm

  • Ethernet not showing

    I recently purchased a refurb Mac Pro.  For some reason I can't get the ethernet port to work.  I ran a diagnostics and it doesn't even show up as active. Any help would be appreciated. I was thinking about purchasing a USB-to-Ethenet adapter if all

  • Printing pictures on deskjet 1050

    When I print picture at a 4x6 picture paper size it will print a gap in the edge of the paper, when I change the setting to fit the page it still prints that gap. I have tried changing the printer setting to the size of paper but there is no change,

  • Get line that contains and then get the second and fourth line after that.

    So I have a text file and I want it to find all the lines in the file that contain an @ symbol and then I want it to get that line and the line second and fourth from that line. Then I would export it like this: $linewith@ + ":" + $secondline + ":" +