How can I make CONTAINS query work for a date range

In either 9i or 10g (eventual). I have a CONTEXT index that contains multiple columns from multiple tables and using a USER_DATASTORE. E.g., I have names that come from 3 different table locations and dates that come from 4. I can index them fine but how can I perform a single consolidated CONTAINS query against the single CONTEXT index to do the following:
smith WITHIN lname AND john WITHIN fname AND dob BETWEEN '19870315' and '19970315'
I know that I can use a mixed query but this is inefficient (esp since I have birth dates in multiple tables). Is there any algorithm for a range operator (>, <, between?) within the CONTAINS operator?
CTXCAT index is not an option, as I have many text columns I am searching.
Thanks!

When you run the cdstore.sql, in addition to creating the ctx_cd package, it also creates the friedman package that contains the algorithm that the ctx_cd package uses. You could use the functions from that friedman package in your procedure for your user_datastore and in the creation of your query string, as demonstrated below.
SCOTT@orcl_11g> CREATE OR REPLACE PROCEDURE my_proc
  2    (p_rowid IN           ROWID,
  3       p_clob     IN OUT NOCOPY CLOB)
  4  AS
  5  BEGIN
  6    FOR r IN
  7        (SELECT emp.ename, emp.job, emp.hiredate, dept.dname
  8         FROM      emp, dept
  9         WHERE  emp.deptno = dept.deptno
10         AND      emp.ROWID = p_rowid)
11    LOOP
12        DBMS_LOB.WRITEAPPEND (p_clob, 7, '<ename>');
13        DBMS_LOB.WRITEAPPEND (p_clob, LENGTH (r.ename), r.ename);
14        DBMS_LOB.WRITEAPPEND (p_clob, 8, '</ename>');
15        DBMS_LOB.WRITEAPPEND (p_clob, 5, '<job>');
16        DBMS_LOB.WRITEAPPEND (p_clob, LENGTH (r.job), r.job);
17        DBMS_LOB.WRITEAPPEND (p_clob, 6, '</job>');
18        DBMS_LOB.WRITEAPPEND (p_clob, 7, '<dname>');
19        DBMS_LOB.WRITEAPPEND (p_clob, LENGTH (r.dname), r.dname);
20        DBMS_LOB.WRITEAPPEND (p_clob, 8, '</dname>');
21        DBMS_LOB.WRITEAPPEND (p_clob, 10, '<hiredate>');
22        -- apply friedman algorithm to date column ------------------
23        friedman.init
24          (TO_NUMBER (TO_CHAR (TO_DATE (19000101, 'YYYYMMDD'), 'J')),
25           TO_NUMBER (TO_CHAR (TO_DATE (21001231, 'YYYYMMDD'), 'J')));
26        DBMS_LOB.WRITEAPPEND
27          (p_clob,
28           LENGTH (friedman.encodedate (r.hiredate)),
29           friedman.encodedate (r.hiredate));
30        --------------------------------------------------------------
31        DBMS_LOB.WRITEAPPEND (p_clob, 11, '</hiredate>');
32    END LOOP;
33  END my_proc;
34  /
Procedure created.
SCOTT@orcl_11g> SHOW ERRORS
No errors.
SCOTT@orcl_11g> BEGIN
  2    CTX_DDL.CREATE_PREFERENCE ('my_datastore', 'USER_DATASTORE');
  3    CTX_DDL.SET_ATTRIBUTE      ('my_datastore', 'PROCEDURE', 'my_proc');
  4  END;
  5  /
PL/SQL procedure successfully completed.
SCOTT@orcl_11g> CREATE INDEX my_index ON emp (ename)
  2  INDEXTYPE IS CTXSYS.CONTEXT
  3  PARAMETERS
  4    ('DATASTORE     my_datastore
  5        SECTION GROUP CTXSYS.AUTO_SECTION_GROUP')
  6  /
Index created.
SCOTT@orcl_11g> EXEC DBMS_STATS.GATHER_TABLE_STATS (USER, 'DEPT')
PL/SQL procedure successfully completed.
SCOTT@orcl_11g> EXEC DBMS_STATS.GATHER_TABLE_STATS (USER, 'EMP')
PL/SQL procedure successfully completed.
SCOTT@orcl_11g> VARIABLE cstring VARCHAR2(4000)
SCOTT@orcl_11g> BEGIN
  2    :cstring := 'smith WITHIN ename';
  3    :cstring := :cstring || ' AND ' || 'clerk WITHIN job';
  4    :cstring := :cstring || ' AND ' || 'research WITHIN dname';
  5    -- apply friedman algorithm to search criteria ---------------------------
  6    friedman.init
  7        (TO_NUMBER (TO_CHAR (TO_DATE (19000101, 'YYYYMMDD'), 'J')),
  8         TO_NUMBER (TO_CHAR (TO_DATE (21001231, 'YYYYMMDD'), 'J')));
  9    :cstring := :cstring || ' AND ((' ||
10               friedman.integercontainscriteria
11                 (TO_NUMBER (TO_CHAR (TO_DATE ('19800315', 'YYYYMMDD'), 'J')),
12                  TO_NUMBER (TO_CHAR (TO_DATE ('19810315', 'YYYYMMDD'), 'J')),
13                  'B')
14               || ') WITHIN hiredate)';
15    ---------------------------------------------------------------------------
16  END;
17  /
PL/SQL procedure successfully completed.
SCOTT@orcl_11g> SET AUTOTRACE ON EXPLAIN
SCOTT@orcl_11g> SELECT *
  2  FROM   emp
  3  WHERE  CONTAINS (ename, :cstring) > 0
  4  /
     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
      7369 SMITH      CLERK           7902 17-DEC-80        800                    20
Execution Plan
Plan hash value: 1887222286
| Id  | Operation                   | Name     | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT            |          |     1 |    37 |     4   (0)| 00:00:01 |
|   1 |  TABLE ACCESS BY INDEX ROWID| EMP      |     1 |    37 |     4   (0)| 00:00:01 |
|*  2 |   DOMAIN INDEX              | MY_INDEX |       |       |     4   (0)| 00:00:01 |
Predicate Information (identified by operation id):
   2 - access("CTXSYS"."CONTAINS"("ENAME",:CSTRING)>0)
SCOTT@orcl_11g>

Similar Messages

  • How can I make the thesaurus work for spanish words?

    I have been using pages for about 4 months now, and usually I use it in english. I am currently writing a document in spanish but I can't manage to make the thesaurus, dictionary and wikipedia work for spanish words. I really need this to find synonyms.
    Any idea what do I need to do? I don't want to change the whole pages into spanish, nor I want the spanish spell check (I know how to do that), I only need the thesaurus.

    Dear me, doesn't Español work?

  • How can i make this query run for a form

    This query works fine for a sql report
    SELECT *
    FROM STUDENTS
    WHERE given_name||' '||family_name = :P101_USERNAME
    AND password = :P101_PASSWORD;
    But i want it to do the same thing for a form but i dont have the option like i do for the report where i can just apply the condition to the process.
    Anyone any ideas how i could do this so that when i go to the form this information is already there based on the username and password from the previous page?

    Assuming that page 101 is your login form, just lookup the primary key of the student based on the values presented in the login page fields, then set and pass this value to the form page.
    So you would create a process that runs near the very end of the the login processes on page 101, something like this:
    declare
    l_student_id students.student_id%TYPE;
    begin
    select student_id into l_student_id from students where  given_name||' '||family_name = :P101_USERNAME and password = :P101_PASSWORD;
    -- then set the value of your form page primary key field
    :P1_STUDENT_ID := l_student_id;
    end;I've done something similar and it works fine for me, although I haven't looked at it recently.
    Earl

  • How Can I Make TouchEvent.TOUCH_BEGIN work for a Slider?

    Hi,
    I'm building an application that has a slider. The slider works great using TOUCH_BEGIN, TOUCH_MOVE, and TOUCH_END events. The problem occurs when the user is touching anywhere else on the screen then uses another finger to move the slider at the same time. The slider will not function. The first touch is being detected by the parent of the parent of the slider.
    I know it has something to do with a TOUCH_BEGIN event being registered by the first touch. But using evt.touchPointID and setting a touchMoveID value (as suggested in Adobe's docs) doesn't seem to have any affect. Also, setting mouseEnabled to false on the slider.parent.parent clip does not help which I really don't get at all.
    Can anyone help me figure this out? Is there a way to ignore the other TOUCH_BEGIN event or a way to prevent it in the first place?
    Many thanks!

    Once I activate the slider with a begin event, the slider moves no matter where I am on the screen. This is because I put the event listener for the move and end events on the stage. The slider is not a component. I built it. I'm using the code under the Touch Point ID section found here as a model:
    http://help.adobe.com/en_US/as3/dev/WS1ca064e08d7aa93023c59dfc1257b16a3d6-7ffe.html
    Thanks for your persistence. I've been at this for several hours today.

  • How can i make the valueChangeListener works for all item under foreach?

    Hi,
    My jspx file have the following content:
    <af:forEach items="#{pageFlowScope.directiveStep.paraItems}"
                                                       var="item">
                                              <af:panelLabelAndMessage label="#{item.name}"
                                                                       id="plam2"
                                                                       for="soc1">
                                                 <af:panelGroupLayout id="pgl2"
                                                                      layout="horizontal">
                                                    <af:selectOneChoice id="soc1"
                                                                        value="#{item.howValue}"
                                                                        required="true"
                                                                        valueChangeListener="#{pageFlowScope.directiveStep.howToSetDirectivePropValueChange}"
                                                                        autoSubmit="true">
                                                       <f:selectItem value="Set Value}"
                                                                      id="si1"/>
                                                      <f:selectItem value="Choose a Value"
                                                                      id="si1"/>
                                                    </af:selectOneChoice>
                                                    <af:switcher facetName="#{item.selectWay}"
                                                                 id="switch1">
                                                       <f:facet name="true">
                                                          <af:selectOneChoice id="soc2"
                                                                              required="true"
                                                                              value="#{item.value}">
                                                             <f:selectItems value="#{pageFlowScope.directiveStep.procVarItems}"
                                                                            id="si2"/>
                                                          </af:selectOneChoice>
                                                       </f:facet>
                                                       <f:facet name="false">
                                                          <af:inputText id="it1"
                                                                        required="true"
                                                                        value="#{item.value}"/>
                                                       </f:facet>
                                                    </af:switcher>
                                                 </af:panelGroupLayout>
                                              </af:panelLabelAndMessage>
                                           </af:forEach>
    The ui is like:
    label name     |    selectOneChoice : 'Set Value' or 'Choose a Value'   |        inputText (if it is 'Set Value') / selectOneChoice (if it is 'Choose a Value')
    The weird thing is when i click the selectOneChoice of the two or later row, the ValueChangeListener will be invoked, it indeed change the value  of 'selectWay' correctly. But the UI will not update. If later i do the same thing to the first row, all other rows in UI will update corrently.
    Any suggestions? Very appreciated for any repiles.
    Thanks.

    Hi,
    on problem I spot is that all your components created by the forEach loop have the same ID value. I suggest you change the ID to e.g. id="soc_#{item.index}" for zhe select one choices. In addition, I don't see where you refresh components after the change
    Frank

  • I just bought a (used) Iphone 3gs for wife and it had angry birds and $89 Navigation on it (I paid extra for it).  Once updated and logged into my I-tunes it no longer works? How can I make those apps work?

    I just bought a (used) Iphone 3gs for wife and it had angry birds and $89 Navigation on it (I paid extra for it).  Once updated and logged into my I-tunes it no longer works? How can I make those apps work?

    Apple doesn't have anything to do with this other than enforcing the DRM protection. The developers of this content expect to be paid if someone wants to use their content. When you purchase content in the app store, you purchase a license to use the content. This license does not permit you or anyone else to resell or give this content away. The individual you purchased the phone from simply does not have the right to sell or give away any purchased content on the phone. You were deceived.

  • How can I make my movies pro for mac work?

    How can I make my movies pro for mac work?
    I have downloaded it i click on the icon but I cant make it work

    Delete the app using this free utlity > Download AppCleaner for Mac
    Then re download the app using the same Apple ID it was originally purchased from. You won't be charged again.
    How to re download apps from the Mac App Store:
    Open the App Store. From the menu bar click Store > Sign In
    Click Purchases from the top of the App Store window.
    Select which apps you want to re download. Then right or control click where you see Installed  then click Install.
    If you still have problems, I located the app developer's website. Contact details for help here >   http://www.mymovies.dk/about.aspx

  • My Iphone 3gs wont charge, turn on, or restore itself in Itunes, but the apple logo still appears when I hold the sleep botton.  How can I make my Iphone work????

    My Iphone 3gs wont charge, turn on, or restore itself in Itunes, but the apple logo still appears when I hold the sleep botton.  How can I make my Iphone work????  I know it is not dead because I can see the apple logo on, and every time I connect it to a USB port to charge, or a wall charger, the battery appears with a bit of red. Still, it wont turn on.  It's been like this for three days now and I haven't stopped charging it.  IT just WONT charge?  Any tips I can use to solve the issue?
    -Esteban

    Hello estebie67,
    Thanks for the question, and welcome to Apple Support Communities.
    It sounds like the iPhone is experiencing issues upon startup, and may not be loading the firmware or operating system correctly. If you have not already done so, try resetting the iPhone while connected to power:
    iPhone, iPad, iPod touch: Turning off and on (restarting) and resetting
    http://support.apple.com/kb/HT1430
    If the above does not resolve your issue, it will be best to restore the iPhone in recovery mode:
    iOS: Unable to update or restore
    http://support.apple.com/kb/HT1808
    Thanks,
    Matt M.

  • How can I make a query by date with several TDMS files?

    Hi,
    I have a project that can write and read TDMS files everyday (a file for each day with date and time). There, I can import those files to excel (I choose a file and load it). But, I have a question: How can I make a query by date with those TDMS files? I'd like make a time stamp for start date and stop date, where I could compare the TDMS file dates and sum the values that are in the channels where these files are similar. For example, I save a file with "02/01/2013" name, in other day "03/01/2013", in other day "04/01/2013"... so, i'd like put in time stamp for start date "02/01/2013" file and to stop date "04/01/2013" file, than, sum all values that range with my TDMS files existing. How can I make that? 
    Thanks all,
    Val 

    Hello Val_Auto.
    You're Brazilian, no? Me too. = ^ - ^ =
    I converted VI to version of your LabVIEW (8.5). Is attached in this reply.
    This VI search all your TDMS in a range of dates and join them in a single TDMS. I hope this is what you wanted.
    Query TDMS is the main VI. The TDMS VI Search changes the date format that out from calendar control (which is DD / MM / YYYY) to DD-MM-YYYY. This is because you can't name files using "/". I chose "-" but, if necessary, you should change to keep the same format of your TDMS files.
    If you have any doubt as to its operation or how to make changes to adapt VI for your application, keep at your disposal.
    Thank you for your contact; I hope have helped you and succeed in your application.
    Wesley Rocha
    Application Engineer
    National Instruments Brazil
    Visite a nossa comunidade em PORTUGUÊS!!!
    Attachments:
    Query TDMS.vi ‏62 KB
    tdms search.vi ‏24 KB

  • How can I make my query to compare only columns of two tables... not the storage information?

    11GR2
    =-----------------------------------
    I am using below querry to compare two table that has same name, under two different users... But after making storage information false like below and  if the storage information is different on column level than it create "Alter modify " statements for the column ... How can I make my query to compare only columns of two tables... not the storage information?
    begin
    DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'PRETTY', TRUE);
    DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'SQLTERMINATOR',TRUE);
    DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'SEGMENT_ATTRIBUTES', FALSE);
    DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'STORAGE', FALSE);
    DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'TABLESPACE',FALSE);
    DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'CONSTRAINTS',FALSE);
    DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'REF_CONSTRAINTS',FALSE);
    DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'CONSTRAINTS_AS_ALTER',FALSE);
    End;
    select REGEXP_REPLACE(dbms_metadata_diff.compare_alter('TABLE','TABLE_NAME_A','TABLE_NAME_A','USER1','USER2'),('USER1...'),'', 1, 0, 'i') from dual

    I am using below querry to compare two table that has same name, under two different users... But after making storage information false like below and  if the storage information is different on column level than it create "Alter modify " statements for the column ... How can I make my query to compare only columns of two tables... not the storage information?
    If you want help you have to SHOW us what you are doing and how you are doing it; you can't just try to tell us in your own words.
    We can't see your computer screen.

  • How can I make a intro page for my website, then after the intro has run make the page automatically change to my we site home screen

    how can I make a intro page for my website, then after the intro has run make the page automatically change to my website's home screen

    You can do this using a meta refresh but the problem is you have to add it to the html file for the page very time you publish changes.
    A better way is to create a splash page and upload it to the server outside of the folder produced by iWeb. Example HERE.
    The meta refresh is added to the head section of the html file...
    <meta http-equiv="refresh" content="32;url=http://www.domain.about.com/Page-Name.html">
    The delay time in seconds is marked in blue and the URL to the redirect page is in red.

  • How can I make a bootable disk for Mountain Lion?

    How can I make a bootable disk for Mountain Lion?

    Make Your Own Mountain/Lion Installer
    1. After downloading Mountain/Lion you must first save the Install Mac OS X Mountain/Lion application. After Mountain/Lion downloads DO NOT click on the Install button. Go to your Applications folder and make a copy of the Mountain/Lion installer. Move the copy into your Downloads folder. Now you can click on the Install button. You must do this because the installer deletes itself automatically when it finishes installing.
    2. Get a USB flash drive that is at least 8 GBs. Prep this flash drive as follows:
    Open Disk Utility in your Utilities folder.
    After DU loads select your flash drive (this is the entry with the mfgr.'s ID and size) from the left side list. Click on the Partition tab in the DU main window.
    Under the Volume Scheme heading set the number of partitions from the drop down menu to one. Set the format type to Mac OS Extended (Journaled.) Click on the Options button, set the partition scheme to GUID then click on the OK button. Click on the Partition button and wait until the process has completed.
    Select the volume you just created (this is the sub-entry under the drive entry) from the left side list. Click on the Erase tab in the DU main window.
    Set the format type to Mac OS Extended (Journaled.) Click on the Options button, check the button for Zero Data and click on OK to return to the Erase window.
    Click on the Erase button. The format process can take up to an hour depending upon the flash drive size.
    3. Locate the saved Mountain/Lion installer in your Downloads folder. CTRL- or RIGHT-click on the installer and select Show Package Contents from the contextual menu. Double-click on the Contents folder to open it. Double-click on the SharedSupport folder. In this folder you will see a disc image named InstallESD.dmg.
    4. Plug in your freshly prepared USB flash drive. You are going to clone the content of the InstallESD.dmg disc image to the flash drive as follows:
    Double-click on the InstallESD.dmg file to mount it on your Desktop.
    Open Disk Utility.
    Select the USB flash drive from the left side list.
    Click on the Restore tab in the DU main window.
    Select the USB flash drive volume from the left side list and drag it to the Destination entry field.
    Drag the mounted disc icon from the Desktop into the Source entry field.
    Double-check you got it right, then click on the Restore button.
    When the clone is completed you have a fully bootable installer that you can use without having to re-download Mountain/Lion.
    Note: The term Mountain/Lion used above means Lion or Mountain Lion.

  • How can I make a "property node" for a VI?

    Hello!
    If I add a boolean button on the FP then I am able to make a property node for that button in the Block Diagram. But how can I make a property node for a VI? I have several VI:s an that together is one program. What I need to do is to verify what kind of VI some of my VI:s is. I need to verify if it is .exe or .vi-file, and if it is .exe then I want to disable run, abort, run continuously bottons otherwise not. I have hard that this is possible to do programmaticaly but I can´t figure out how. I am aware that I could do that manually in the File->vi properties->customize->windows appearance but theese choises makes it last forever.
    I want to be able to stop and run and everything if it is a .vi file, but if it is .exe-file then all those buttons should be disabled.
    Anyone have an example on this?
    In an other message at this Forum I read "You can use the `Front Panel Window. Allow Runtime PopUp`" property to disable run-time shortcuts menues programmaticaly, but still I dont know how to create this property node.
    /Amir

    You really shouldn't open a new thread. If you don't understand something, ask and we will explain it.
    Like I said in the other thread, you can check if you are running in LV or an EXE by using the Application>>Kind property. To get it, place a property node (from the Application Control palette) on the diagram, click it and find the property.
    To set the properties for the VI, place another property node, right click it and select Select Class>>VI Server>>VI. You should have the properties you want under Front Panel Window.
    To learn more about LabVIEW, I suggest you try searching this site and google for LabVIEW tutorials. Here and here are a couple you can start with. You can also contact your local NI office and join one of their courses.
    In addition, I suggest you read the LabVIEW style guide and the LabVIEW user manual (Help>>Search the LabVIEW Bookshelf). I believe chapter 17 of the user manual explains about programmatic control of VIs.
    Try to take over the world!

  • I bought an Apple Airport and the light is flashing a yellow light! I did this because I live in a basement and the modem is in the first floor. I followed the instruction manual and the Airport is not working still. how can I make my Airport work?

    How can I make the Airport work?

    If there is a modem and not a router on the first floor, then the only possible way to get it to work would be an Ethernet cable connection between the modem and the AirPort Express device.
    I think you need to describe your situation in more detail.

  • Realtek network card seems to be disappeared. how can i make it visible again for the OS?

    i can't access my LAN card. somehow it is disappeared. how can i make it visible again for the OS? my OS is windows 7. thanks very much for your help

    right click on the button bar, then select "customize toolbar", drag any button you like into the toolbar and you're done!
    Diego

Maybe you are looking for