Equivalent of CONTAINs clause?

Using Oracle 11g
I have a table transaction as below
Transactionid     type     entiy
1                 edit       currency
1                      edit       party
2                      edit       currency
2                      edit       xyz
2                      edit       party
3                      edit      currency
3                      edit      abcI need to find those transactionid which involves currency , but doesn’t involve party in it. Ie my expected output should be
Transactionid     type     entiy
3 edit currency
3 edit abc
Do we have an operator which is something like CONTAINS .. so that I can specify select from . ….where CONTAINS (currency) BUT NOT CONTAINS(PARTY) group by transactionid?
Thanks,
S

This is just to complete the set of approaches.
select * from transactions
where transactionid in ( select transactionid from transactions
                                  where type = 'edit' and entity = 'currency'
                                  minus
                                  select transactionid from transactions
                                  where type = 'edit' and entity = 'party')
{code}
Depending on the relative skew of values in teh table this might perform better or worse than the EXISTS solutions already posted.
Cheers, APC                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • Contains clause in Interactive report search of a clob column

    Hi,
    I am using APEX Version 4.2.4.00.08
    How can an interactive Report use the contains clause when searching a clob column so that it uses the CONTEXT index?
    Thanks
    Chandra.

    I wrote it into the SQL used for the IR
    I created an APEX application that stores all of our IT's HOWTO documents. (word,excel,pdf)
    ctx_doc.snippet creates HTML code.
    select D.doc_id
      ,D.doc_filename
      ,dbms_lob.getLength( D.doc_blob ) as download
      ,decode( :P12_SEARCH, null, '-- nothing --',
             ctx_doc.snippet( 'IT_DATA.DOC_CTX_IX' -- my Oracle Text index name
                                 , D.doc_id, :P12_SEARCH )
       as snippet
    from it_data.documents D
    where :P12_SEARCH is null
    or contains( D.doc_blob, :P12_SEARCH ) > 0
    MK

  • Using xsql params w/in oracle text "contains" clause

    Hello,
    Regarding the xsql code below:
    <?xml version="1.0"?>
    <?xml-stylesheet type="text/xsl" href="hrefs.xsl"?>
    <page connection="rxschema" xmlns:xsql="urn:oracle-xsql">
    <xsql:query file="%winping-utility%" version="1.0"
    null-indicator="yes" link="">
    select distinct c.contentpathname
    from rx_schema.ct_shared s, rx_schema.contentstatus c
    where s.contentid = c.contentid
    and contains (s.ul_file, '{@link} within href') > 0
    and s.revisionid = (select max(revisionid)
    from rx_schema.ct_shared
    where contentid = s.contentid)
    order by contentpathname
    </xsql:query>
    </page>
    specifically this line:
    and contains (s.ul_file, '{@link} within href') > 0
    This query doesn't work, I think the "{@link}" xsql param (passed in) is being interpreted as an xml attribute (since it's within the "contains" clause), is there a way to force it to read this as a param? I also tried it w/o the braces (and I also verified that it works when I hardcode a value in place of "@link").
    Thanks,
    JSK

    The syntax of a 'Contains' query should contain only the 'Contains' query operators.
    http://www.cise.ufl.edu/help/database/oracle-docs/text.920/a96518/cqoper.htm#1360

  • CONTAINS clause still works after disabling fulltext index on a table

    I disabled the fulltext index on a table using the below query:
    USE <dbname>;
    GO
    ALTER FULLTEXT INDEX ON <table_name> DISABLE
    Per BOL, "The table will not support full-text queries while the index is disabled.", I would expect the CONTAINS clause to stop working but I can still return rows from the <table_name> as before.
    SELECT top 10 * 
      FROM [dbo].[table_name]
      WHERE CONTAINS(<column>, N'test');
    The above returns 10 rows before and after disabling the index.
    Do i need to do something else?
    I even tried DENY permissions:
    DENY CONTROL, TAKE OWNERSHIP, ALTER, REFERENCES, VIEW DEFINITION ON FULLTEXT CATALOG::<catalog_name>
    TO <some_database_roles including public>
    Please help.
    Thanks
    Thanks

    Charles,
    Do you have any DDL Triggers on your server that might affect whether the full text index could be disabled?
    Any Policies that might likewise affect your results?
    RLF

  • What is equivalent to 'with clause' in oracle

    what is equivalent to 'with clause' in oracle
    thanks

    My reqirement is :
    I have a table named egroup. I have to find the name of the egroup different from "other" that can be found in the most countries in Africa
    create table EGROUP(
         c_id     char(2), -- country id
         egroup     varchar2(40), -- name of the ethnic group
         percent number(4,2), -- percentage of population
         constraint egroup_fk foreign key(c_id) references COUNTRY,
         constraint egroup_pk primary key(c_id,egroup)
    insert into egroup values('AF','Pashtun', 42 );
    insert into egroup values('AF','Tajik',27 );
    insert into egroup values('AF','Hazara',9 );
    insert into egroup values('AF','Uzbek',9 );
    insert into egroup values('AF','Aimak',4 );
    insert into egroup values('AF','Turkmen',3 );
    insert into egroup values('AF','Baloch',2 );
    insert into egroup values('AF','other',4 );
    insert into egroup values('AL','Albanian', 95 );
    insert into egroup values('AL','Greek',3 );
    insert into egroup values('AL','other',2 );
    insert into egroup values('AG','Arab-Berber', 99 );
    insert into egroup values('AG','European',1 );
    insert into egroup values('AQ','Samoan (Polynesian)', 89 );
    insert into egroup values('AQ','Caucasian',2 );

  • Oracle 11G + Single sdata searching in Contains clause

    Hi,
    Their is one domain index in my table on valueaddxml column, and another column is of queryid which is of varchar2(500)
    Their are two records in the table.
    one is :-
    valueaddxml - > <?xml version="1.0" encoding="UTF-8"?><valueaddinfo><seqno>679</seqno></valueaddinfo>
    queryid = 2
    second is :-
    valueaddxml - > <?xml version="1.0" encoding="UTF-8"?><valueaddinfo><seqno>888</seqno></valueaddinfo>
    queryid = 1
    the output of following query is :-
    select queryid from v2_1244160000_1251936000 where contains(valueaddxml,'( haspath(/valueaddinfo\[seqno="679"\]))') > 0 and contains(valueaddxml,' (sdata(queryid = ''1'')) ') > 0 order by istimestamp desc
    Output :- queryid - > 2
    I dont know why oracle is showing such kind of behaviour with only sdata in contains clause.
    Can i use contains(valueaddxml,' (sdata(queryid = ''1'')) ') > 0 clause ?
    Is it compulsary to use other 'within' or any other clause with sdata ?
    any help please ?
    Edited by: PulkitSogani on Aug 12, 2009 12:23 AM

    Let me make it more clear.
    If i use this query (wrong output ):-
    select queryid from v2_1244160000_1251936000 where contains(valueaddxml,'( haspath(/valueaddinfo\[seqno="679"\]))') > 0 and contains(valueaddxml,' (sdata(queryid = ''1'')) ') > 0 order by istimestamp desc
    Output is :- queryid = 2
    If i use query ( Correct output ) :-
    select queryid from v2_1244160000_1251936000 where contains(valueaddxml,'( haspath(/valueaddinfo\[seqno="679"\])) and (sdata(queryid = ''1'')) ') > 0 order by istimestamp desc
    Ouput is :- no data avaliable.
    Why can not i use the first one instead of second ?
    Edited by: PulkitSogani on Aug 12, 2009 12:21 AM
    Edited by: PulkitSogani on Aug 12, 2009 12:22 AM
    Edited by: PulkitSogani on Aug 12, 2009 12:23 AM

  • CONTAINS clause and keywords

    We have an application which uses context indexes, and a user ran the following query today which resulted in an error:
    select *
    from paghtrd a
    where CONTAINS(A.NAME, 'ALL ABOUT AUTOS') > 0;
    SQL Error: ORA-29902: error in executing ODCIIndexStart() routine
    ORA-20000: Oracle Text error:
    DRG-50901: text query parser syntax error on line 1, column 11 It's because "ABOUT" is a keyword. For instance, the following runs without a problem
    select *
    from paghtrd a
    where CONTAINS(A.NAME, 'ABOUT (AUTO)') > 0How do people handle these keyword entries? Does your interface strip them out when building the SQL?
    Thanks,
    --=Chuck

    You need to escape the reserved words if you want to use them in your search term.
    If they are single character reserved symbols like '&' then you can use backslash like this '\&'
    If ther are reserved words like ABOUT,ACCUM, AND ,FUZZY then you need to use curly brackets {} to escape them.
    >
    So does your interface do a "search & replace" on keywords, before inserting a user's entry into a CONTAINS( ) clause? "ABOUT" is only one of many keywords.
    >
    No, When you escape a reserved word, When reading the search term it simply treats it as a normal word.
    G.

  • Intermedia .. Contains clause

    Hello:
    I am trying to get a query that parses out a CLOB ( XML tags) to work but I get an error when I use an OR with the Contains clause.
    Error:
    ORA-29902: error in executing ODCIIndexStart() routine
    ORA-20000: Oracle Text error;
    DRG-50901: text query parser syntax error on line 1, column 2
    Part of the query that I am using is as follows :
    SELECT
    a.subj_key_val_txt, func_ctct_hist_xml_parse(XMLTYPE(a.adt_xml_desc).extract('/EVENT/CONTACT_HISTORY'), 'csrFirstName'), func_ctct_hist_xml_parse(XMLTYPE(a.adt_xml_desc).extract('/EVENT/CONTACT_HISTORY'), 'csrLastName'),
    a.adt_crt_dtm adt_crt_dtm, func_ctct_hist_audit_event(ae.adt_evt_typ_name,(XMLTYPE(a.adt_xml_desc).extract('/EVENT')) )
    FROM
    audit_v3 a,
    audit_evt_type_v3 ae
    WHERE
    a.adt_evt_typ_id = ae.adt_evt_typ_id and
    CONTAINS(a.adt_xml_desc, to_char(cons_seq_nbr_in) || ' WITHIN CONS_SEQ_NBR') > 0 or
    CONTAINS(a.adt_xml_desc, to_char(member_id_in) || ' WITHIN WITHIN MEMBER_ID') > 0
    and
    trunc(a.adt_crt_dtm) between start_date_in and end_date_in
    * when I remove the second CONTAINS clause, it does not give any errors... but that also means that I don't get a full set of data back
    Could someone help me with this issue?
    If I have a clob with xml tag as this : <EVENT><MEMBER_ID>12345</MEMBER_ID><CONTACT_HISTORY><MEMBER_ID>999999</MEMBER_ID></CONTACT_HISTORY></EVENT>
    how can I code the CONTAINS to look for the Member_ID value within <CONTACT_HISTORY> within <MEMBER_ID> and not in <EVENT><MEMBER_ID> ?
    Thank you so much for your help, everyone.
    This site with questions and answers is a big help to my daily tasks.

    Sorry, I do not have 2 WITHIN in the second Contains clause ..
    CONTAINS(a.adt_xml_desc, to_char(cons_seq_nbr_in) || ' WITHIN CONS_SEQ_NBR') > 0 or
    CONTAINS(a.adt_xml_desc, to_char(member_id_in) || ' WITHIN MEMBER_ID') > 0

  • Contains clause

    I have a question on the contains clause.
    Do I need the % symbol surrounding the search string? Example - I have a user_name column in the database with a value "[email protected]". Why does this query not return anything:
    select * from users where contains(USER_NAME, 'jell')>0
    The index is as follows:
    CREATE INDEX "TESTSCHEMA"."U_USER_NAME_DOMAIN" ON "TESTSCHEMA"."USERS" ("USER_NAME")
    INDEXTYPE IS "CTXSYS"."CONTEXT" PARAMETERS ('SYNC(ON COMMIT)');

    I hope this link help you.
    [http://www.dba-oracle.com/t_sql_contains_clause.htm]
    Regards salim.
    Oracle gives this example of invoking the SQL contains clause:
    CREATE TABLE accumtbl
       (id NUMBER, text VARCHAR2(4000) );
    INSERT INTO accumtbl VALUES
       ( 1, 'the little dog played with the big dog
          while the other dog ate the dog food');
    INSERT INTO accumtbl values
       (2, 'the cat played with the dog');
    CREATE INDEX
       accumtbl_idx ON accumtbl (text)
       indextype is ctxsys.context;
    PROMPT dog ACCUM cat
    SELECT
       SCORE(10)
    FROM
       accumtbl
    WHERE
       CONTAINS (text, 'dog ACCUM cat', 10) > 0;

  • Explain plan changes by result size from contains clause

    I use 10.2.0.3 Std Edition and have a query like this
    select t1.id from table1 t1
    where t1.col99 = 123
    and t1.id in (select ttxt.id from fulltexttable ttxt where contains (ttxt.thetext, 'word1 & word2'));
    (note: for each row in table1 exists at least one corresponding row in fulltexttable)
    Now I came across a surprising change in execution plans depending on the values of word1 and word2:
    - if the number of result rows from the subquery is low compared to all rows the full text index is used (table access by rowid/domain index)
    - if the number of result rows is high explain plan does not indicate any use of the domain index (full text index) but only a full text table scan. And the slow execution proves this plan.
    But: if I create explain plan for the subquery only there is no difference whether the number of result rows is high or low: the full text index is always used.
    Any clue for this change in execution strategy?
    Michael

    hi michael,
    this is expected behaviour. because you have a query incorporating more than just a text-index, and furthermore, multiple tables, the optimizer may choose different access paths according to the cardinality of your where clause terms. in fact, anything you see is actually vanilla behaviour.
    however, as i suppose, you probably have not yet heard about the "post filter" characteristic of a context index. see the tuning chapter of the text dev guide for more info. also note that the optimizer has no other way than accessing the context index directly iff you execute the subquery on its own (the "post filter" characteristic is not applicable here, because a post filter always needs some input to be filtered). and finally, be aware that oracle may unnest your subquery by its own decision, that is, do not try to force a direct context index access by a subquery, it will not work (a compiler hint is the only thing that works relyably).
    the only thing i can not follow is the fts for your second example. dont you have join indexes on table1.id and fulltexttable.id, respectively?
    p

  • How do I use Contains clause to find an XML value within a CLOB

    Hello:
    ( I have also posted this question on the PL/SQL forum )...
    I have a table with a CLOB column ( adt_xml_desc). Within it there is a value of "<EVENT><PINREQUEST TYPE='1'> .........
    I am trying to query the row with the following sql :
    select * from audit_v3 v where v.adt_id = 7418442 and
    CONTAINS(v.adt_xml_desc, '(1 WITHIN PINREQUEST@TYPE)') > 0;
    I am not getting any values back although the row is there. Any suggestion would be greatly appreciated.
    Thank you.

    Hi
    I am not sure if my problem is similar to this one but ...
    I am trying to extract all the cities listed in this column of xmltype.
    Example -
    <whrcond id = 1>
         <one>
              <value src="cities" type="cities"
              Chicago
              </value>
         </one>
    </whrcond>
    <whrcond id = 2>
         <one>
              <value src="cities" type="cities"
              NYC
              </value>
         </one>
    </whrcond>
    Anyone?

  • Insertion into local table from remote table with contains clause

    Hi all,
    We are tasked to insert some rows into our database from another database. We tried to use DBLinks to link the 2 databases and were able to use Select statements to filter out the data that we need to insert into our database.
    These statements take the form of: Select * from RemoteTable where contains@RemoteLink(IndexColumn, 'car')>0;
    where RemoteLink is the DBLink that we have created.
    However Oracle gave us an error (ORA-00949: illegal reference to remote table) when we tried to insert the dataset from the above statement into our local table. We used the following statement in doing so: Insert Into LocalTable (Select * from RemoteTable where contains@RemoteLink(IndexColumn, 'car')>0);
    Even if we use Create Table, Oracle gave us the same error when we tried to push the data from the Select Statement into the new table.
    Could anyone advise us whether it is possible to insert such data into a local table? And if som what is the proper way of doing it?
    Many thanks to any advises.

    Hi,
    there is document 261741.1 on Metalink. This states explicitly that it is not possible to invoke remote user-defined operators, and contains is such. The solution given in the article is to create a wrapper function on the remote site and this one calling in stead of contains.
    Herald ten Dam
    htendam.wordpress.com

  • CONTAINS clause and the ORA-29902 error.

    Hello folks,
    I am encountering the following error in APEX.
    report error:
    ORA-29902: error in executing ODCIIndexStart() routine
    ORA-20000: Oracle Text error:
    DRG-10825: stored query does not exist: employee
    DRG-10825: stored query does not exist: employee
    Here is the rest of the information :
    1. I have created the index on the column in question as specified here.
    bq. {color:#0000ff} CREATE INDEX{color} \\ {color:#0000ff} \\ emp_idx ON meta_eul (display_name){color} \\ {color:#0000ff} \\ indextype is ctxsys.context; \\ {color}
    2. I have created the sqe for the word as suggested [here |http://download-west.oracle.com/docs/cd/B19306_01/text.102/b14218/cqrypkg.htm#i997218]: employee
    bq. {color:#0000ff} begin{color} \\ {color:#0000ff} \\ ctx_query.store_sqe('employee', 'empl or emp');{color} \\ {color:#0000ff} \\ end;{color}
    3. When I execute the following sql in sql developer, I get results
    bq. {color:#0000ff} SELECT SCORE(1), A.DISPLAY_NAME \\ FROM meta_eul a \\ WHERE 1 =1 \\ AND CONTAINS(A.DISPLAY_NAME , 'sqe(employee)', 1)&gt; 0 \\ ORDER BY SCORE(1) \\ {color}
    4. I have the same query in #3 above as a region in my Page.
    When I execute it, I get the error that I have mentioned above.
    Any thoughts ? Is this a limitation ?
    I am on Apex version 3.0
    Regards,
    Atul

    Thanks, Roel.
    A similar option that worked out as an alternative is that I have changed the region code to :
    bq. {color:#0000ff}SELECT SCORE(1), A.DISPLAY_NAME \\     FROM meta_eul a \\     WHERE 1 =1 \\     AND CONTAINS(A.DISPLAY_NAME , 'emp or empl or employee', 1)&gt; 0 \\     ORDER BY SCORE(1) \\ {color}
    and have avoided the sqe part. This doesn't seem to have an issue in Apex.

  • Contains clause using like

    Hi
    I need to get data using contains from a text the data will be like A,AA,AA1,AA2
    if i give AA1 it should fetch all the data .I cant use like operator here pls suggest

    Such wonderful details you've provided us with to be able to help you.... not.
    Try posting sufficient details as per the forum FAQ: {message:id=9360002}

  • Select List with a Contains clause (oracle text)

    Hi, I am trying to create a dynamic select list, but am running into problems using bind variables.
    I am trying to do this:
    select distinct country d, country r
    from table1
    where contains(:P6_LIST_VALUE,''''|| :P6_NAME||'''');
    I keep getting the error: "LOV query is invalid, a display and return value are needed, the column names need to be different...."
    If I hard code the :P6_LIST_VALUE to be 'NAME' (which is what I named my context index) it works fine:
    where contains(name, ''''||:P6_NAME||'''');
    Is there any way to get around this error?

    anonymous - Please tell us your first name.
    CONTAINS Operator
    Syntax
    CONTAINS(
    [schema.]column,
    text_query VARCHAR2
    [,label       NUMBER])
    RETURN NUMBER;
    So you can't use a bind variable for the column name, just like you can't do "SELECT :COL FROM DUAL".
    Try &P6_LIST_VALUE. (with trailing period). This effects a textual substitution before the SQL is parsed.
    Scott

Maybe you are looking for

  • Automating Group, Sub Group, Folder and Sub Folder Creation

    I am relatively new as an administrator, and this may be a simple question. I need to publish similar groups and folders for 30 instances. I am able to complete this through the CMS functionality, but I was wondering if there was some form of command

  • Time Machine snapshots, but no hourly backups

    System: MBP (late 2011), 2.8 GHz i7, 16 GB RAM, Mavericks 10.9.5, Samsung SSD and Samsung HDD in lieu of optical drive. Running Bootcamp too. My technical acumen: ample and extensive...but I am stumped. Problem: in September 2014, I noticed that my h

  • WRT54GS v7.0 firmware link wrong

    When I go to the WRT54GS downloads page (http://www.linksysbycisco.com/US/en/support/WRT54GS/download), select version 7.0, it displays firmware Ver.7.50.6 available, but the link actually points to the firmware for WRT54GS v.5-6, Ver.1.52.6. The rel

  • Transport hang

    Hi All, Cannot transport CEB transports to CEB system. All the transports are hanging. Kindly check the Tp system logs in STMS for more errors details. They are many requests awaiting for CEP via CEB. Kindly look into this ASAP The error message in T

  • Roles in su01

    in SU01  Which roles we need to give to wokflow developer and workflow admin . Regards ajay.