Getting the ROWIDs of non-duplicate rows in Oracle 10g

Hi,
given a table TAB1 in which the primary key is composed of these first 3 columns:
================================================
colA____________colB_________________colC____________________colD
================================================
AA-----------------------01-----------------------20080101-----------------------100
BX-----------------------32-----------------------20050325-----------------------366
AA-----------------------01-----------------------20080102-----------------------645
AA-----------------------01-----------------------20080707-----------------------765
AB-----------------------02-----------------------20080806-----------------------336
AB-----------------------02-----------------------20080705-----------------------543
I wish to be able to find the ROWIDs of those rows where colA||colB occurs only once in the table TAB1.
So in the above example, I would want to know the ROWID of the row containing colA=BX and colB=32 as "BX32" occurs only once in this table (AA01 occurs 3 times, AB02 occurs twice so I'm not interested in them).
The following does work, but it is too SLOW:
select ROWID from TAB1 where colA||colB = (select colA||colB from TAB1 HAVING COUNT(*)=1)
Can anyone please suggest an efficient way to find this unique ROWID value in these circumstances?
Edited by: Nemesis on Nov 29, 2008 2:50 AM

Thank you Walter.
This does not give the desired result however. It compares the table, row by row with a 'mirror' of itself and says 'give me the rowid of the row where its mirror does not match itself' (correct me if I am wrong)
(Here I added the '=' to ' AND d.ROWID = d1.ROWID);'
SELECT D.rowid
FROM TAB1 D
WHERE NOT EXISTS (SELECT *
FROM TAB1 d1
WHERE d1.COLA = d.COLA
AND d1.COLB = d.COLB
AND d.ROWID = d1.ROWID);
So it returns nothing as all rows match their mirror rows.
However, it gave me the idea of doing the following:
SELECT D.ROWID FROM TAB1 D WHERE (SELECT COUNT(*) FROM TAB1 D1 WHERE X.colA = D.colA AND X.colB = D.colB )=1;
Which works, and seems a little faster than my original query, so thank you for this.

Similar Messages

  • Getting the ROWID of a Row

    I'm trying to develop a generic OCI class which is also capable
    of inserting, updating and deleting records.
    Is there an OCI function which gets the ROWID of a returned row
    without having to explicitly specify it in the SELECT clause of
    the query ? At present the fields that make up the primary key
    or unique index have to be specified in the SELECT.
    Does anyone know how the OO4O Class Library gets round this
    problem ?
    Upto now I have been using OO4O but now wish to migrate to OCI
    for compatibility reasons.

    If it is a SELECT for UPDATE, the ROWID is implicitly returned .
    It can be retrieved by calling OCIAttrGet on the statment handle.

  • Columns to rows in oracle 10g

    Hi,
      I need the output from columns to rows in oracle 10g.
    this is my original output using some select query,
    select a.created_by,b.modified_by from created_tp a,modified_tp b where a.col_id=b.col_id.
    created_by       modified_by
    Siva                 Raja
    but i need this same output by rows like
    user--anything fine
    Siva
    Raja
    Thanks
    Siva

    Hi,
    select case l when 1 then a.created_by
    else b.modified end
    from created_tp a,modified_tp b, (select level l from dual connect by level <= 2)
    where a.col_id=b.col_id.

  • How to get the last transaction in a row in SQL Developer?

    What syntax would I use to get the last transaction of a row in SQL developer?
    The way I have my query set-up currently it is not returning the correct data, here is my current syntax:
    select ssn, max(tran_id), chng_type,tran_id
    from pda_tran
    where ssn = 'xxx-xxx-0011'
    and chng_type = 'C'
    group by ssn, chng_type,tran_id;
    It returns a 'C' chng_type but it is not the last one. when I query on this ssn this is what I get:
    ssn tran_id chng_type
    xxx-xxx-0011 001 A
    xxx-xxx-0011 002 E
    xxx-xxx-0011 003 C
    xxx-xxx-0011 004 S
    xxx-xxx-0011 005 C
    xxx-xxx-0011 006 T
    I only want to return the ssn's with a last transaction chng_type of 'C'. How can I get the correct information returned. Please advise.

    From what I see and read... there is one to many group by
    You wrote
    select ssn, max(tran_id), chng_type,tran_id
    from pda_tran
    where ssn = 'xxx-xxx-0011'
    and chng_type = 'C'
    group by ssn, chng_type,tran_id;
    If you want the max(tran_id), remove it from the "group by"
    select ssn, chng_type, max(tran_id)
    FROM
    (SELECT 'xxx-xxx-0011' ssn, '001' tran_id, 'A' chng_type FROM DUAL UNION
    SELECT 'xxx-xxx-0011' ssn, '002' tran_id, 'E' chng_type FROM DUAL UNION
    SELECT 'xxx-xxx-0011' ssn, '003' tran_id, 'C' chng_type FROM DUAL UNION
    SELECT 'xxx-xxx-0011' ssn, '004' tran_id, 'S' chng_type FROM DUAL UNION
    SELECT 'xxx-xxx-0011' ssn, '005' tran_id, 'C' chng_type FROM DUAL UNION
    SELECT 'xxx-xxx-0011' ssn, '006'tran_id, 'T' chng_type FROM DUAL )
    where ssn = 'xxx-xxx-0011'
    and chng_type = 'C'
    group by ssn, chng_type;

  • How Can we get the data from Non-SAP to SAP in WebDynpro

    Hi,
    I hope u understand my query, How can we get the data from Non-SAP to SAP thru WebDynpro Programming.
    Help out with the steps for getting the data or procedure.
    Regards,
    Mutyapu

    You can expose the APIs in the Non-SAP backend as Web Services, and consume them in SAP by creating an Enterprise Proxy. Then these can be called just like normal class methods from Web Dynpro.
    Regards,
    Nithya

  • HT1918 How do you solve an issue with the card? I don't get the option of 'none' :(

    How do you solve an issue with the card? I don't get the option of 'none'

    I had this exact same problem with the new iPhone I bought on 1/4/13. The walk through they provide on how to do this is useless because it fails to explain that if you are already having the problem of not getting the "None" payment option with an Apple ID then you will need to create a completely new Apple ID.
    I had to do this 7 times since I bought my iPhone on Friday until this morning to figure out how to finally be able to use the Home Sharing option in iTunes to put my music collection on my brand new $500.00 iPhone. Pretty pathetic if you ask me but since it made me so angry I want to make sure other know how to do this so you don't get as upset as I did.
    #1 If your current or soon to be "old" Apple ID is not providing the option for "None" as a payment option then you need to make a brand new one. But you have to make it specifically how I tell you.
    #2 You will need to use an email address that has not already been used for anything related to a previous Apple ID. You might need to make a brand new email address.
    #3 Open iTunes, then open iTunes Store (upper right corner of iTunes).
    #4 Click on App Store (upper center of screen).
    #5 Scroll down the screen page until you see Top Free Apps on the right side.
    #6 Choose any one of the FREE apps.
    #7 You should either get the option to create a new Apple ID box, either that, or it will pop up with some kind of disclaimer and then it does the create new Apple ID.
    Either way just create a new Apple ID when it gives you the option to and then when you get to the page that looks like the payment page the "None" payment option will finally be available.
    Note: You will still have to fill out the information on the payment page. As long as you choose the "None" option it will not request any credit card information.
    #8 You will be sent a confirmation email to the new email account. Just follow through with what ever it tells you and viola now you can use your Apple Device.
    What a pain in the keester, eh?

  • HT2731 I am using ipad2 with the latest version. While trying to make a apple Id, In the payment information  cannot get the option of "none" what will I do. Please help.

    I am using ipad2 with the latest version. While trying to make a apple Id, In the payment information  cannot get the option of "none" what will I do. Please help.

    You are following the instructions on this page for creating a new account : http://support.apple.com/kb/HT2534 e.g. selecting a free app in the store and tapping on 'create Apple id' when 'buying' the app ? I've just tried it and it works for me

  • Getting the MD5 of an entire ROW ?

    Hi All,
    I'm looking for how to get the MD5 of an entire row (or a known set of columns).
    I've found the DBMS_OBFUSCATION_TOOLKIT.MD5 function, which takes either "input IN RAW" or "input_string IN VARCHAR2" as a parameter.
    So, I've three questions:
    1) Is is possible to get the entire value Row in a manner to pass into this function? (e.g. As a String)
    2) Is this DBMS_OBFUSCATION_TOOLKIT package only in Enterprise edition and not in Standard edition ? (How do I check this)
    3) or Is there a better way to get the MD5 of a Row ??
    My row of data will contain a column of type MDSYS.SDO_GEOMETRY.
    Cheers,
    Ronan

    Still no luck with that one...
    select DBMS_OBFUSCATION_TOOLKIT.MD5( input_string => TO_CHAR( ROUTEN ) ) ) AS MD5 FROM interstates;
    ERROR at line 1:
    ORA-00907: missing right parenthesis
    I've seen examples, using that input_string, but only in a procedure, I can't get it to work through a standard SQL statement.
    For example:
    SQL> SET SERVEROUTPUT ON;
    SQL> BEGIN
    2 DBMS_OUTPUT.PUT_LINE (
    3 'md5 hash => ' ||
    4 DBMS_OBFUSCATION_TOOLKIT.MD5 (
    5 input => UTL_RAW.CAST_TO_RAW ('plain text'))
    6 );
    7 END;
    8 /
    md5 hash => 31BC5C2B8FD4F20CD747347B7504A385
    PL/SQL procedure successfully completed.
    SQL> SELECT DBMS_OBFUSCATION_TOOLKIT.MD5 ( input => UTL_RAW.CAST_TO_RAW ('plain text')) FROM DUAL;
    SELECT DBMS_OBFUSCATION_TOOLKIT.MD5 ( input => UTL_RAW.CAST_TO_RAW ('plain text')) FROM DUAL
    ERROR at line 1:
    ORA-00907: missing right parenthesis

  • Getting the background color from a row

    I'm displaying a table that has alternating row colors for odd and even... when I click on a row I am changing the color to blue. When I click on a different row I want to set the background color back to what it was for the originally selected row and change the currently selected row to blue. This worked just fine when I had the colors hard coded into the code... but as soon as I started using style sheets it stoped working,
    My questions is how do I get the background color from a row... for instance, the following alert dislays nothing. How can I get the actual color out for the row?
    var tableElem = document.getElementById('table');
    var rowElem;
    rowElem = tableElem.rows[0];
    alert(rowElem.bgColor);
              

    If you're working with style sheets, then ignore the background color. You don't want to care what color is actully being used, only that the correct style is in place.
    Worry instead about the className property for your row:<style>
    .highlightRow {
       color: white;
       background-color: gray;
    .normalRow {
       color: black;
       background-color: white;
    </style>
    var tableElem = document.getElementById("table");
    var rowElem = tableElem.rows[0];
    alert(rowElem.className);
    <table id="table">
    <tr class="normalRow"><td>...</td></tr>
    <tr class="highlightRow"><td>...</td></tr>
    </table>

  • What is the maximum number of characters in an Oracle 10G Instance Name

    All,
    Can I know what is the maximum number of characters in an oracle 10g instance name under AIX? Is it 7 characters or 8 characters?
    regards
    Santhosh

    One should really make the difference between db_name and instance_name: if instance_name default value is db_name it can be different
    (even on a non RAC database).
    For example with Oracle 10.2.0.4 you can create a database named DB78 with instance_name=DB12345678:
    $ uname -a
    Linux lx01.localdomain 2.6.18-92.el5 #1 SMP Fri May 23 22:17:30 EDT 2008 i686 i686 i386 GNU/Linux
    $ ps -fu oracle | grep smon
    oracle    6353     1  0 20:30 ?        00:00:01 ora_smon_DB12345678
    oracle    6412  5596  0 20:37 pts/1    00:00:00 grep smon
    $ export ORACLE_SID=DB12345678
    $ sqlplus / as sysdba
    SQL*Plus: Release 10.2.0.4.0 - Production on Wed Sep 8 20:34:26 2010
    Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> show parameter name
    NAME                                 TYPE        VALUE
    db_file_name_convert                 string
    db_name                              string      DB78
    db_unique_name                       string      DB78
    global_names                         boolean     FALSE
    instance_name                        string      DB12345678
    lock_name_space                      string
    log_file_name_convert                string
    service_names                        string      DB78I would not recommend this practice: but it's interesting to know to avoid confusing between db_name and instance_name.

  • WEBUTIL_FILE.Get File Separator must be declared error in oracle 10g

    hi,
    when i compile the forms with attached webutil.pll , i got the error "WEBUTIL_FILE.Get File Separator must be declared error in oracle 10g".but i have compiled the webutil.pll its fine.Please tell me th solution.
    Thanks,
    Maran

    hi
    hmmmm the latest version of webutil.pll you downloaded from where? forms version 10.1.2... comes with the latest version of .pll.
    what is the webutil version?
    sarah

  • How to check/find the size of current ROLLBACK segment in oracle 10g

    How to check/find the size of current ROLLBACK segment in oracle 10g ? Kindly help

    A rollback segment name like "_SYSSMU231$" is used when you have Automatic Undo Management enabled.
    The only relevant parameters are :
    1. UNDO_MANAGEMENT=AUTO
    2. UNDO_RETENTION=n minutes ==> this is what everyone should be interested in
    3. The sizes of the Undo Tablespace datafiles and whether AUTOEXTEND is ON or OFF
    No one should be interested in the size of a single undo segment when Automatic Undo Management is enabled.
    Possible causes of ORA-01555 errors in Automatic Undo Management
    a. UNDO_RETENTION is too low
    b. Undo tablespace is too small
    Hemant K Chitale

  • See the detalis of DDL commands executing on oracle 10g

    Hi,
    how can i see the detail of DDL command executed on oracle 10g on ECC 6.0
    ECC 6.0
    HPUX
    Regards,

    Did you activated the auditing mechanish on the Oracle? If it is active, you can query the audit table;
    select * from sys.aud$;
    Another way is using Oracle Log Miner. You can find the related information, on the link below;
    http://docs.oracle.com/cd/B10501_01/server.920/a96521/logminer.htm
    Best regards,
    Orkun Gedik

  • How to get the RowID in a VO

    Hi All,
    I have a expert mode VO. Its not a EO based VO. I need the row id in the VO query. But it throws me an ora-01445 error. I need the rowid because I need to pass it as a parameter to a procedure. How can i get this done. Any help is greatly appreciated.
    Thanks,
    Sreeram.

    HI,
    This is my sql query in the VO I am trying to develop:
    SELECT * from (SELECT aid.rowid,
    aid. ACCOUNTING_DATE,
    aid. DISTRIBUTION_LINE_NUMBER,
    aid. INVOICE_ID,
    aid. ACCRUAL_POSTED_FLAG,
    aid. ASSETS_ADDITION_FLAG,
    aid. ASSETS_TRACKING_FLAG,
    aid. CASH_POSTED_FLAG,
    aid. DIST_CODE_COMBINATION_ID,
    aid. LAST_UPDATED_BY,
    aid. LAST_UPDATE_DATE,
    aid. LINE_TYPE_LOOKUP_CODE,
    aid. PERIOD_NAME,
    aid. SET_OF_BOOKS_ID,
    aid. INVOICE_DISTRIBUTION_ID,
    aid. AMOUNT,
    g.code_combination_id,
    g.segment1,
    g.segment2,
    g.segment3,
    g.segment4,
    g.segment5,
    g.segment6,
    ppa.segment1 as Project,
    pt.task_number as TASK,
    aid.expenditure_type,
    aid.expenditure_item_date,
    hao.name as name
    FROM AP.AP_INVOICE_DISTRIBUTIONS_ALL aid,
    GL.GL_CODE_COMBINATIONS g,PA.pa_projects_all ppa, PA.pa_tasks pt, apps.hr_all_organization_units_tl hao
    WHERE aid. invoice_id = 19498
    AND LINE_TYPE_LOOKUP_CODE in ('ITEM')
    AND aid. DIST_CODE_COMBINATION_ID =g.code_combination_id
    AND aid.project_id = ppa.project_id(+)
    AND aid.task_id = pt.task_id (+)
    AND aid.expenditure_organization_id = hao.organization_id (+)) QRSLT where 1=2
    But it gives me this error:
    SQL QUERY ERROR MESSAGE:ORA-01445 Cannot select rowid from, or sample a join view with out a key-preserved table.
    Btw..this is a custom application.
    Any pointers on this..
    Thanks,
    Sreeram.
    Edited by: SreeramKosaraju on Jun 29, 2009 9:58 AM

  • How to get the ROWID in a Trigger?

    On Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit when I try below script I always get the same Rowid as "AAAAAAAAAAAAAAAAAA". Is this normal?
    Thank you.
    create table testrowid (a number );
    create or replace trigger testrowidbins
    before insert on testrowid for each row
    begin
    dbms_output.put_line( 'Rowid:= ' || :new.rowid );
    end;
    set serveroutput on
    insert into testrowid values( 1 );
    insert into testrowid values( 2 );
    insert into testrowid values( 3 );
    rollback ;
    insert into testrowid values( 1 );
    insert into testrowid values( 2 );
    insert into testrowid values( 3 );
    commit ;
    insert into testrowid values( 1 );
    insert into testrowid values( 2 );
    insert into testrowid values( 3 );
    rollback ;

    Well, it was more of a rhetorical question.
    Rowid is the physical location of a row in a table. During the execution of a BEFORE trigger, the row has not yet been placed in the table hence the 'AAAAA' rowid.
    During your AFTER trigger, the row exists in the table and therefore has a normal rowid.

Maybe you are looking for

  • Why does recievig partnerrequire outbound parameter setting for the message

    Hi,     I was configuring the partner profiles for outbound billing and sales order cycles.Interestingly for outbound scenario, we had to maintain the settings for outbound parameters in receiving partner. For example, if i sending ORDERS  message ty

  • How to Create ODBC Data Source (DSN)  Programmably?

    Very troublesome to go to control panel and manually create the Data Source. Anyone know of any free Java Library which enables us to do it from a Java program?

  • Portal Menu - possibilty of export

    Hi, is there possibility of dynamic exporting and importing menu (or fragment of menu such a set of iViews assigned do role) to the portal (for example in xml file). The problem is that I want to develop portal application and present it on the porta

  • Trouble with Illustrator CS5 Trial Installation on Mac

    Hi Everyone, I am trying to install the trial version of Illustrator CS5. I am using the Adobe Download Assistant and it has produced an error. The error is number 4960 and it says that the disk image for Illustrator could not be opened. If anyone co

  • Base amount of a tax

    How to get the base amount of a tax deducted through system (which is already configured through system)