Duplicating a query across multiple fields

Hi
We have a form for looking-up person information. It consists of a single-record block (PERSON) with fields like PERSON.PERSON_SURNAME and PERSON.PERSON_FORENAME. User's use the built in Enter Query and Execute Query buttons to find records. However, there are also fields such as PREVIOUS_SURNAME which users often don't bother to query which results in them creating duplicate records when they don't find the record they're looking for.
I was wondering if there's a way to capture the query that the user has entered and extend it to other fields? For example, if they entered 'SMITH%' in the PERSON_SURNAME field, instead of the form creating the query:
"select * from person where PERSON_SURNAME like 'SMITH%'"
it would run:
"select * from person where PERSON_SURNAME like 'SMITH%' or PREVIOUS_SURNAME like 'SMITH%'"
Also, some users forget to include a % in their query so I was hoping there was a way to effectively add one to every query automatically.
This would be fairly straight-forward if we used a custom query button but is there any way to do it while still using the built-in toolbar buttons?
Thanks

Thank you both for your replies. I tried Craig's suggestion and created this KEY-EXEQRY trigger:
declare
     xwhere   varchar2(2000);
begin
xwhere := null;
if :PIN is null and :UPN is null then --User doesn't know specific details so do fuzzy search
     if :PUPIL_SURNAME is not null then
          :PUPIL_SURNAME := :PUPIL_SURNAME||'%';
          xwhere := '(pupil_surname like '''||:PUPIL_SURNAME||''' or prevname like '''||:PUPIL_SURNAME||''')';
     end if;
     if xwhere is not null and :PUPIL_FORENAMES is not null then
          xwhere := xwhere||' and ';
     end if;
     if :PUPIL_FORENAMES is not null then
          :PUPIL_FORENAMES := :PUPIL_FORENAMES||'%';
          xwhere := xwhere|| '(pupil_forenames like '''||:PUPIL_FORENAMES||''' or preffname like '''||:PUPIL_FORENAMES||''')';
     end if;
     if xwhere is not null and :PUPIL_DATE_OF_BIRTH is not null then
          xwhere := xwhere||' and ';
     end if;
     if :PUPIL_DATE_OF_BIRTH is not null then
          xwhere := xwhere||'pupil_date_of_birth = '||:PUPIL_DATE_OF_BIRTH;
     end if;
     SET_BLOCK_PROPERTY ('PUPIL',DEFAULT_WHERE,xwhere);
end if;
execute_query;
end;The problem is, it seems to be disregarding the SET_BLOCK_PROPERTY function or overwriting it after the trigger. Adding the % seems to work (line 7) because I'm literally changing the contents of the field but the other fields aren't being queried. I don't believe simply setting
:PUPIL_SURNAME := :PUPIL_SURNAME||'%';
:PUPIL_PREVIOUS_SURNAME := :PUPIL_SURNAME;would work because forms will treat this as and AND query and I need it to be an OR.
Any other suggestsions?
Thanks
Edited by: Andrew V on May 24, 2013 11:05 AM

Similar Messages

  • Import Format script required to work across multiple fields

    I am currently constructing an Import Format, and using datapump import scripts on several of the fields to implement specific logic based on the values present. For example:
    Function TBNetwork(strField, strRecord)
    If Left(strField, 1) = "N" Then
    TBNetwork = strField
    Else
    TBNetwork = "Network N/A"
    End If
    End Function
    However, I need this to also evaluate the values across other fields too, but the default two inputs for the function are strField and strRecord.
    How can I achieve this? Can I declare new variables and define as follows?
    Dim strCustomer = varValues(23)
    Or do I need to look at implementing a different type of script? Any suggestions would be greatly appreciated!

    strRecord represents the entire data line from your source file that is currently being processed. You can parse this to get any of the values from your data line to use/evaluate in your script. There is an accelarator script DW.Utilities.fParseString which will do the string parsing for you. As you probably know strField only returns the field from the data file that you have specified in your import format for the associated dimension.

  • Full text query across multiple columns

    In the SQL Server, when you do the full text query, you can specify multiple columns, e.g.
    FREETEXT ( { column_name | [b](column_list) | * } , 'freetext_string' [ , LANGUAGE language_term ] )
    CONTAINS ( { column_name | [b](column_list) | * } , '< contains_search_condition>' [ , LANGUAGE language_term ])
    Where,
    column_list Indicates that several columns, separated by a comma, can be specified...
    * Specifies that all columns in the table registered for full-text searching should be used to search for the given contains search condition. The columns in the CONTAINS clause must come from a single table...
    That makes full text query cross multiple columns very convenient. Are there any mechnisms in Oracle to do the same thing?
    Thanks in advance.

    Thanks for your reply.
    I knew that you could build full text index for the multiple columns using Oracle Text. But that does not solve my problem, which is how to build the query to search multiple columns at once. Say, I have columns firstname, lastname, address, and email in the table customers. I want to get the results that ANY column contains 'bob'. In SQL Server, I can do
    select * from customers where contains(*, 'bob')
    that is. But for Oracle, I have to do
    select * from customers where contains('firstname', 'bob') or contains('lastname', 'bob') or contains('address', 'bob') or contains('email', 'bob')
    Can you imagine if I have many columns in many tables and I have to do the query against all columns in all tables? I have to dynamically get all the columns and then build the query string.
    So, any better solutions?

  • Sql query across multiple tables ina database

    I have 3 MS Access tables in database that are linked by keyed fields in the table.  Is there a way to fetch only certain records that match a criteria across all three of these tables using the database connectivity toolset VIs?

    Thanks.  I am trying to mechanize/run an SQL query like this 
    SELECT Code_Type.Code_NUM, Code_Type.Code_Word, Word_Type.Parm_Label, Word_Type.Word_Sequence, Word_Type.Num_Words, Parameter_Label.Parm_Label, Parameter_Label.Parm_Name, Parameter_Label.Num_Bits, Parameter_Label.Num_Bits
    FROM (Code_Type INNER JOIN Word_Type ON Code_Type.Code_Word = Word_Type.Code_Word) INNER JOIN Parameter_Label ON Word_Type.Parm_Label = Parameter_Label.Parm_Label;
    while using the VIs in the database connectivity toolset.  How do I code this using these VIs?  I dont see an example of a straight SQL string like this being able to be put into the VIs.

  • How to use ServerApplicationContext to do a remote query across multiple entities

    Hello everybody,
    My data model is like this:
    "Case" -> one-to-many -> "Document"
    Document has  the fields:
    - "IsFinalised" (boolean)
    -  File (large binary)
    My business rule is: 'a Case is closed if all its documents are finalised'.
    I am trying to do a query which returns whether a case is closed using ServerApplicationContext, but I don't want the query to load the large binaries for each Document into memory for given case.
    Does this do the job?
    int IsCaseClosed(int caseId)
    using (var sac = ServerApplicationContext.CreateContext())
    var relevantCase = sac.DataWorkspaces.ApplicationData.Cases.FirstOrDefault(c => c.Id = caseId);
    return relevantCase.Documents.All(d => d.IsFinalised);

    I think what you have is pretty close.  I would probably write it like this:
    bool IsCaseClosed(int caseId)
    bool isClosed = false;
    if caseId > 0
    using (var sac = ServerApplicationContext.Current ?? ServerApplicationContext.CreateContext())
    isClosed = sac.DataWorkspace.ApplicationData.Cases_Single(caseId).Documents.All(d => d.IsFinalised);
    return isClosed;

  • Running sql query across multiple (remote) databases

    I'd like to run a query that pulls information from multiple databases which are not on the same machine. Is this possible using SQL Developer?

    If you are still interested, there is a tool that can query multiple databases and save results in a single text file that you can then modify as necessary - see www.bsutils.com/MuSQL.html

  • How to create a combined numeric limit across multiple fields?

    Hello,
    I need to create a form where users can select multiple beneficiaries for thier insurance and must input the percent they want for each beneficiary. The total for all fields must equal 100%. Is there anyway to create a table or bind fields together so that their totals must equal 100? Also, I want them to be able to add or delete rows if they want to add or delete beneficiaries. Any help would be much appreciated, thanks.

    Hi Jerun,
    There's no way to do that. You'll need to run separate reports and merge them in Excel.
    -m

  • Best workaround for querying across multiple Data Sets?!

    Hi folks
    Today I was migrating my older OEID 3.0 applications to 3.1, and I noticed some of my older version views are not working anymore in new version.
    We used to have multiple Bulk Add/Replace (without specifying Collection Keys) and we could use any attributes from any of these, in a certain View for example.
    My views were like SELECT SUM("an attribute/metric from Bulk Add_1") / SUM("an attribute/metric from Bulk Add_2")
    Now that you have to specify a FROM clause in your views, and it has to be from a certain Data Set, whats the best way to achieve above line goal?
    Bests,

    Patrick
    What I meant by Cross Join is Cartesian Product in situation that you have many-to-many relations between 2 Data Sets
    Lets say, I have to different data, coming from 2 totally different source, one from Sales Dept and the other one from Purchase Dept:
    Sales Table:
    Part Number
    Sales QTY
    Sales Date
    Part Type
    Manufacturer
    Country
    0001
    70
    10/5/2012
    TYPE1
    Manuf1
    US
    0001
    120
    10/6/2012
    TYPE1
    Manuf1
    US
    0001
    350
    10/7/2012
    TYPE1
    Manuf1
    US
    0002
    100
    10/8/2012
    TYPE2
    Manuf2
    US
    0002
    80
    10/9/2012
    TYPE2
    Manuf2
    CA
    0003
    2500
    10/10/2012
    TYPE3
    Manuf3
    CA
    0004
    180
    10/11/2012
    TYPE4
    Manuf4
    US
    Purchase Table:
    Part Number
    Purchase QTY
    Purchase Date
    Part Type
    Manufacturer
    Country
    0001
    50
    10/5/2012
    TYPE1
    Manuf1
    US
    0001
    60
    10/6/2012
    TYPE1
    Manuf1
    US
    0001
    100
    10/7/2012
    TYPE1
    Manuf1
    US
    0001
    200
    10/8/2012
    TYPE1
    Manuf1
    US
    0002
    1100
    10/9/2012
    TYPE2
    Manuf2
    US
    0003
    20
    10/10/2012
    TYPE3
    Manuf3
    US
    What is the preferred approach to ingest this data?

  • Preferred approach - Querying Across Multiple Schemas

    All,
    I am using two schemas within the same database as the source for my OBIEE repository/subject area. My question is whether anyone has a compelling argument or preference for setting up OBIEE to handle requests across the schemas as either:
    1. Set the connection pool property to 'Require Fully Qualified Table Names'
    2. Setup synonyms between the schemas for the tables that need to be exposed
    Just curious how others do it. I believe Synonyms may add on a small performance hit but I believe it would be negligible compared to qualifying the table with the schema name.
    Thanks,
    K

    There is no overhead in using synonyms to an object in another schema. In fact that's the best practice in my opinion. We have 3 DWHs in OBIEE each in its own schema. We also have a special OBIEE_RO account that has only select grants to all DWH objects and synonyms for all of them. We coded a script that generates all the grants and synonyms so we can re-run it when we add new objects. This assures we can use a single account for a OBIEE which is much more simpler to maintain. It also means we can share conformed dimensions between different DWHs.

  • Query across multiple databases

    Hi,
    One shot question: is it possible in Oracle to write a query joining two tables from different databases ?
    I used MS SQL, and it was duable there, but I have to port app to Oracle, and I did not manage to do this on oracle.
    I use oracle 9
    Thanks.
    pesq

    1. Create an account on the remote database with permissions to select from the relevent tables.
    2. Create a database link in the local database to connect to the account (step 1.) in the remote database.
    3. Now execute you query in the local database connecting to the tables in the remote database.
    SELECT local_a.col1, local_a.col2, rmt_a.col5
    FROM local_table local_a, remote_table@<name of link> rmt_a
    WHERE local_a.key = rmt_a.key;

  • How do you query across multiple datasources?

    I am trying to query data from an Oracle database and a DB2 database using bind variables. (10.1.3.2). I have created a data template as follows:
    <dataTemplate name="PMHUBS">
         <dataQuery>
              <sqlStatement name="Q1" datasourceref="PMDWTST">
                   <![CDATA[select      RGN.RGN_NAME,
             DSTRC.DSTRC_NAME,
          HUB_INFO.EXEL_HUB_TYPE,
          HUB_INFO.TOUCHPT_ID,
          HUB_INFO.EXEL_HUB_TYPE
    from      EXEL_DIRECT.DSTRC DSTRC,
          EXEL_DIRECT.RGN RGN,
          EXEL_DIRECT.HUB_INFO HUB_INFO
    where   DSTRC.DSTRC_ID(+) =HUB_INFO.DSTRC_ID
    and      RGN.RGN_ID(+) =DSTRC.RGN_ID
    Order by       HUB_INFO.TOUCHPT_ID,
    RGN.RGN_NAME,
    DSTRC.DSTRC_NAME,
    HUB_INFO.EXEL_HUB_TYPE]]>
         </sqlStatement>
         <sqlStatement name="Q2" datasourceref="EXBASETD DVLP1">
         <![CDATA[SELECT HBMHBCD FROM EXDBASETD.EMP012
    WHERE HBMHBCD=:TOUCHPT_ID]]>
              </sqlStatement>
         </dataQuery>
    </dataTemplate>
    I get the error message: ORA-00903: invalid table name. Each sql statement works separately. I can take the 2 sql statements and concatenate them and get the XML output, but I seem to be doing something wrong using a data template.
    Help?
    Thanks
    Phil Slater

    I was missing the GROUP part of the dataTemplate!
    I didn't find the manuals that helpful with this. You have to add the datasourceref to each SQL:, and then add a GROUP in a DataTemplate.
    <dataTemplate name="JOINS_TEST " dataSourceRef="EXDBASETD DVLP1">
    <dataQuery>
    <sqlStatement name="DB2 HUBS">
    <![CDATA[     SELECT HBMHBCD
                              FROM EMP012
                             WHERE HBMEXAG = 'E'
                         AND HBMSTAT = 'ACTV'
                    ORDER BY HBMHBCD
                    ]]>
    </sqlStatement>
    <sqlStatement name="ORACLE HUBS" dataSourceRef="PMDWTEST">
    <![CDATA[     
                    SELECT TOUCHPT_ID
                      FROM HUB_INFO
                     WHERE EXEL_HUB_TYPE='EXEL'
                 AND :HBMHBCD = TOUCHPT_ID
    ]]>
    </sqlStatement>
    </dataQuery>
    <dataStructure>
    <group name="G_HUBS" source="DB2 HUBS">
    <element name="HBMHBCD" value="HBMHBCD"/>
    <group name="G_ORACLE HUBS" source="ORACLE HUBS">
    <element name="TOUCHPT_ID" value="TOUCHPT_ID"/>
    <element name="REG_ID" value="REG_ID"/>
    </group> -- PMDWTEST
    </group> --- EXDBASETD
    </dataStructure>
    </dataTemplate>

  • Import Format script required to update multiple fields

    Further to my previous post yesterday (Import Format script required to work across multiple fields I now need my import script to update multiple (two) fields at the same time, based on criteria set across multiple fields. So far, I can use DW.Utilities.fParseString to assess the values across multiple fields, but I now need to update not only the field in question, but also an additional field at the same time. For example:
    Function TBService(strField, strRecord)
    ' How do I update a second field at the same time?
    Dim strField2 As String
    If Left(strField, 1) = "S" Then
    If DW.Utilities.fParseString (strRecord, 3, 8, ",") = "B1110" Then
    strField2 = "N101"
    Else
    strField2 = "Network N/A"
    End If
    TBService = strField
    Else
    TBService = "Service N/A"
    End If
    End Function
    Is this even possible? Should I be looking at creating an event script which would work post-import? Or can this be done right here in the import script?

    All the logic you require can be encapsulated in the import script for the second field. You don't need to reference the second field in the first import script.
    Edited by: SH on May 2, 2012 5:39 PM

  • Reg Query For Multiple Text Fields

    Hi all
    I am New to this forum..
    I am developing an application for generating reports.
    In my application i have multiple text fields.
    The user might enter any of the textfields or even enter all the fields.
    In those cases how to use the query when some fields are empty??

    Welcome to the forum.
    It always helps to post a small, simplified example of what it is you're trying to achieve.
    (When posting examples, put the {noformat}{noformat} tag before and after the example, so it will get posted formatted on this forum.)
    In those cases how to use the query when some fields are empty??If your textfields serve as parameters/bind variables for you query, then you could use NVL.
    Something like:select ...
    from some_table
    where col1 = nvl(p_col1, col1)
    and col2 = nvl(p_col2, col2)
    And how about wildcards (the '%' or '_' sign), by the way? Are they allowed as well?
    You also might want to read about this approach:
    http://www.oracle.com/technology/oramag/oracle/09-jul/o49asktom.html                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to build a query across parent and child object fields?

    As a part of an Integration Requirement, I need to query Opportunity records that have been Modified after a specific date and time?
    Now, Opportunity has a child object called ProductRevenue with a one to many relationship. Is there anyway I can construct a querypage that will fetch records whose Opportunity fields 'OR' its child ProductRevenue's fields have been modified after a specific date and time?
    I have tried using the SearchSpec argument, but it does not let me query across child object fields.
    For eg:-
    ObjOpptyQueryPageInput.ListOfOpportunity.Opportunity.searchspec = "([ModifiedDate] > '01/01/2013 00:00:00') OR ([ProductRevenueData.ModifiedDate] >= '01/01/2013 00:00:00')";
    [This above code written in C# thew me an error saying - The object Opportunity does not have an integration component called - ProductRevenueData.ModifiedDate.]
    Any help will be greatly appreciated. Thank you.

    Hi,
    As far as I know this can't be done at once because you have to consider :
    - Every Opportunity and their time-limited ProductRevenues
    AND
    - Time-limited Opportunities
    If you want to achieve this, you have to consider the 2 datasets separately and make your first query :
    ObjOpptyQueryPageInput.ListOfOpportunity.Opportunity.searchspec = "([ModifiedDate] >= '01/01/2013 00:00:00')";
    but also another query with the restriction on the ProductRevenue Searchspec.
    This shouldn't be too hard because the searchspec functionality is present at each level :
    - ListOfOpportunity -> Opportunity (the top-level that you used for your query)
    - ListOfOpportunity -> Opportunity -> ListOfProductRevenue -> ProductRevenue (the sub-level that you should use for the second query)
    Then in your C# code, you merge the 2 datasets and you end up with your expected result.
    Hope this helps,
    Charles.
    http://www.dubant.com

  • How do you get a line with MULTIPLE fields to WRAP ?

    How do you get a line with MULTIPLE fields to WRAP ?
    Good afternoon everyone...
    THE PROBLEM: Why doesn’t a line with multiple fields WRAP?
    HYPOTHETICAL EXAMPLE/WHAT I”D LIKE TO SEE
    If I have 2 fields on a line (this is now a hypothetical example and nothing to do with my actual report)….let’s call them field A and field B. And if field A has values of all ‘X’ and field B has values of all ‘Y’…then….the normal case would be (ignore dots – only for spacing):
    A……………………… B
    XXXXXXXXXXXXXXXXXX YYYYYYYYYYYYYYYYY
    But what if A is too long? I would want to see B wrap onto the next line like this:
    A……………………………………………………B
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX YYYYYY
    YYYYYYYYYYYYY
    And similarly….if B is extra long, can the line print as:
    A………………………. B
    XXXXXXXXXXXXXXXXXXX YYYYYYYYYYYYYYYYYYYYYYYYYYY
    YYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
    I don’t want the case where B is long and I get:
    A………………… …B…
    XXXXXXXXXXXXXXXXX YYYYYYYYYYYYYYYYYYYYYY
    ………………………..YYYYYYYYYYYYYYYYYYYYY
    I can see how you can wrap an individual field like that…but how can you WRAP a line of[b] fields within the frame so it wraps to the BEGINNING of the frame on next line?
    My SPECIFIC CASE
    I have a report that I have stripped down to a simple structure for the purposes of this explanation.
    My DATA MODEL has the main QUERY (for plant family and species data). The columns of the query are divided into 2 groups. The 1st GROUP contains the family data. Below that is the rest of the species data in a 2nd GROUP.
    Linking from the 2nd species group (above) is a new QUERY to extract REGION data based on the common key field. Under this 2nd query is another group with all the REGION columns.
    The LAYOUT MODEL has a group frame (the main , base one)
    On top of this is a repeating frame based on the 1st group (family data).
    On top of this is another repeating frame for the 2nd group (species data).
    On top of this is 2 Frames on the same line line. The 1st frame contains columns from the species group .
    The 2nd frame on this line is a repeating frame. The PRINT DIRECTION for this frame is ACROSS/DOWN. It repeats details of the REGION where the species is found. These columns come from this group come from the REGION QUERY and GROUP.
    All fields on the report line have variable horizontal elasticity.
    The problem is that when there is too much data on the line, it does NOT WRAP to the 2nd line.. It TRUNCATES.
    Can the line be made to WRAP????..
    In my current report, 1 of 2 things is happening:
    1) All fields print on the line until it hits the page boundary and then it just stops. Truncated!
    2) All fields print on the current line, then Oracle Reports throws a new page to print the REMAINDER of the long, input line
    But I would like a LONG line to continue printing onto the following line of the same page.
    I have tried all combinations of the elasticity fields and the ‘ADVANCED LAYOUT’ properties.
    I have been focussing my attention with this problem on the frames .
    We are using REPORT BUILDER V 6.0.8.26.0
    Thankyou to anyone who may offer assistance.
    Tony Calabrese.

    Steve,
    you gain 1 thing, but you lose something else!
    This thing is SO frustrating!
    Hey Steve! Good afternoon.
    I've done as you suggested....I have a long text boilerplate item - the only 1 on the line...and it has all the column in it.
    So it looks like:
    &col1 &col2 &col3 &col4 &col5 etc etc etc
    And the line expands nicely to each field's requirements.
    And when it gets to the right page boundary...it WRAPS to the next line! Beautiful!!!
    The only thing is that...when I had individual fields across the line I was able to create format triggers for those fields. And in doing so I was able to reduce the font and change the justification. I had to do that because some of the fields had to appear superscripted.
    So I wanted something like (ignore the dots):
    ...................................ppppp
    AAAA BBBB CCCCC DDDD EEEE FFFFFF
    So the field of 'ppppp' appeared slightly higher on the line than the other fields...
    I can't see how I can do this with a single TEXT field containing all the &COL values.
    Have you ever come across anything like this?
    Thankyou again,
    Tony Calabrese 12/4/2007

Maybe you are looking for

  • Year wise GL account retained earnings

    Hi Friends, My client has ECC5 version.  This is 2nd year of closing (march 09).   Now he wants 2008 year profit to be posted to Retained Earnings 2008 GL account.Like wise he is asking me to maintain year wise retained accounts. Last year ie 2007, i

  • Read Image From Webpage

    Sorry, posted in wrong forum. Edited by: gms5002 on Mar 4, 2008 12:51 PM

  • How can I save a Image to a GIF file??

    Class Image ---------> GIF file How can I do it??

  • Engineer fixed speed but still low ip profile.

    hi the engineer came and gave me a great boost i never get more than 1919 0r similar so very happy Connection time 0 days, 00:25:55 Downstream 5,307 Kbps Upstream 955 Kbps ADSL Settings VPI/VCI 0/38 Type PPPoA Modulation G.992.3 Annex A Latency type

  • SAP BAS solution

    Hi , We're planning to develop a solution on SAP BAS(business analytic solution). So could anyone please give me some idea on what is BAS and BO(business objects) modelling on the cloud? Thanks and regards, Abhishek Pal Chaudhuri