Parsing a field in CFQUERY WHERE clause

I have a fairly large database that I need to run queries on.  I have one field that represents where store items are stocked by aisle, section and bin. This location field is concatenated with underscore delimiters: aisle_section_bin .  An example location might be 3_25_17.
I need to run queries where I parse this concatenated location field and essentially ask:
SELECT *
FROM MyData
WHERE aisle = '3' AND section '25' AND bin = '1'
Could someone please help me with house this would be done?
My database is fairly large, so I need my queries to be fairly efficient so my server does not timeout.
Thankyou

Hi,
I agree with Claus P; You need to move them to separate fields for a better searching;
I assume that you have those three values separately and in your database those values are concatenated with underscore.
If you sure that your data in the database is only with this format 3_25_17; You could think of using SUBSTR functions in oracle and then use ListGetAt Function in Coldfusion to find it.
Ex: SUBSTR(3_25_17,1) = <cfqueryparam value="#listGetAt(fieldValue, 1, "_")#" />

Similar Messages

  • When formatting a date field in a where clause the template put dot instead of comma

    Hello to Headstart Workers !
    In a query find block the template construct a where clause, in some cases, and i dont know when the template is formatting a date field putting a dot instead of a comma.
    Ex.: to_date('19-01-2001'.'DD-MM-YYYY')
    Anybody knows why or where the template do this.
    Congratulations
    Nelson

    - We created it using the HS utilities.
    - "nls_numeric_character = ,.".
    - it onky happen when the field date is not the first field in the where clause.
    - i can see the problem just after pressing find button, already in the ls_block in last_query.
    - the find_query works normally but cannot edit any line in ls_block.
    Hope that i had helping
    Regards
    Nelson
    null

  • How to dynamically add field name in where clause of select query in web dynpro?

    Hello,
    Can any body tell me how i can use select query with dynamic wheere condition.
    i have a requirement like there are multiple input fields  and i want to select data from two database
    and condition may vary .

    Hi
    In the where clause you need to write like
    WHERE NAME LIKE 'DE%'
    Regards
    Sudheer

  • Finding undisplayable characters in a field with a WHERE clause

    Oracle_Rdb7 for_OpenVMS Release 7.0.1. I have a field in my table that has been loaded with data that contains "return/line feed" characters (I'm not sure of the ASCII hex representation) which can't be displayed and show up as "." on my screen. How can I code a WHERE clause that will find these characters, e.g., SELECT * FROM TABLE1 WHERE NAME CONTAINING <here is where I want to put the ASCII hex value for a "return/line feed" character>? Also, how could I get the actual ASCII hex code for these characters to display, e.g., "31" instead of "1"?

    a 'return' is CHR(10) So you can:
    select * from my_table where text_fld like '%'||CHR(10)||'%'

  • Tuning Select Statement . field sequence and where clause

    Hi All
    Are there any general guidelines how to write select < field sequence >where clause < field sequence ? Is that shuld be in order of the field sequence in tables?
    And how to use this when we have a view or a inner - join . Is that separate from normal select statement that is using FOR ALL ENTRIES.
    Please let me know any general guidelines available on this,
    Amol

    Hello Amol,
    I have another hint:
    The statement FOR ALL ENTRIES will package the select statements for every five entries in the internal table. So in comparison to the following code sequence...
    LOOP AT itab.
       SELECT * FROM table WHERE key = itab-key.
    ENDLOOP
    the number of select statements is reduced to 20% with
    SELECT * FROM table INTO TABLE ...
         FOR ALL ENTRIES IN itab
         WHERE key = itab-key
    If I'm expecting a <i>huge</i>  amount of data a go a step further and create my own packages by building a range table with around 100-500 entries and execute a select there...
    LOOP AT itab.
       IF counter < 500.
          APPEND itab-key TO range-tab.   " just code example
       ENDIF.
       IF count >= 500.
          SELECT * FROM table APPENDING TABLE ...
             WHERE key IN range_tab
       ENDIF.
       " adjust and calculate counter
    ENDLOOP.
    * Don't forget last select statement after loop
    Best wishes,
    Florin

  • Parsing an input parameter for the where clause or record select value

    In my limited CR experience, I've always used a command database connection so that I can write my own SQL.  However, now I have to parse a  pipe delimited parameter to get my value for the where clause, so I'm selecting several tables and joining them through the Database Expert Links tab.  All works fine, but after doing that and then parsing the parameter with the below formula in the Select Expert, I notice that there is no where clause in the SQL query, and although the report eventually displays the proper values, it runs through thousands of records first.  Here is my Select Expert - Record formula:
    StringVar array Parm1;
    Parm1 := Split({?DATA_AREA}, "|");
    {SO_ORDERS.CASE_ID} = Parm1[2]
    If I change "Parm1[2]" on the last line to a valid Case ID, then there is a where clause in the SQL and the report generates immediately. 
    It seems like the record select formula is applied AFTER all of the records (without a where clause) are searched when I use the parsed parameter value, but when I hard code a valid value, it places that into the where clause BEFORE the sql is executed.  Is there a way to get the parameter parsed first and then use that parsed value in the SQL where clause?
    Thanks.
    Bill

    Yes crystal will run the query first to get 100% data and then applies record selection condition. To increase the performance you need to pass the where condition at the command level instead of report level. So you need to create a report using add command like this
    select * from tablename where field={?Parameter}
    {?Parameter} is a command level parameter.
    Now insert this report as a subreport in another report which has no connection but has a parameter
    {?DATA_AREA} and create a formula like this in the main report
    Split({?DATA_AREA}, "|")[2]
    Now right click on the subreport and go to change subreport links and add this formula from main report and link this to sub report parameter {?Parameter} without linking any database field from the subreport.
    Now your subreport runs with the where clause to get the data.
    Regards,
    Raghavendra

  • Pass values dynamically to the WHERE clause in SFAPI

    Hi there
    We have a requirement to pass values dynamically (in the run-time of the interface) to the WHERE condition to our SFAPI query.
    Eg -
    SELECT person, personal_information, address_information, phone_information, email_information, employment_information, job_information, compensation_information, paycompensation_recurring, paycompensation_non_recurring, job_relation, accompanying_dependent,         global_assignment_information, direct_deposit, national_id_card, person_relation
              FROM CompoundEmployee
              WHERE last_modified_on &gt;= to_date('LAST_RUN_DATE')  AND
                           last_modified_on &lt;= to_date('CURRENT_RUN_TIME') 
    LAST_RUN_DATE is stored in a custom entity for which we execute another OData query. The custom entity is updated with the CURRENT_RUN_TIME once the interface has been executed successfully. So the next time the interface is run it picks up the LAST_RUN_DATE from the custom OData entity.
    SAP PO has the functionality to run a dynamic query for OData adapters. Refer to Note 2051137 - PI Successfactors adapter : Dynamic odata query and single synchronous sfapi query
    Eg - select fields from position (this is what you state in OData query path in the comms channel; this is static); and you have an advanced tab in comms channel where you mention dynamicquery and set it to true (this points to a XSD which has the keyword TOP, SKIP & FILTER in it).
    This gets the filter values passed from the BPM from another query (from a OData cust_table).
    So the whole query is - select fields from position filter field a = x field b = y etc. Field a field b are fields in position that are you passing values x and y in run time of the interface.
    SAP PO also has the advanced tab feature for SFAPI for dynamic query.
    Question is -
    how to use it?
    has anyone implemented this before?
    What does XSD will look like?
    How do we pass values to the fields to the Where clause for SFAPI.
    Any ideas are welcome!
    Regards
    Arijit Das

    After you have added a new where clause on the detail VO, try re-executing VO's query by DetailVO.executeQuery()
    If it doesn't work try re-executing the MasterVO's query after you have added the where clause on the detail

  • Using CLOB datatypes in WHERE clause

    Hi All,
    I have a table with two columns as CLOB datatype. I'm using Oracle 8i Enterprise Edition. I can do a query, insert, update and even delete the data in the CLOB field using Oracle's SQL Plus.
    What I want is to do a search on those fields.. that is include that field in a WHERE clause. I'm using this datatype to store large number of data.
    I'd like to see this query working...
    SELECT * FROM MyTable WHERE CLOBFLD LIKE 'Something...';
    Now this query doesn't work. It returns: 'Inconsistent datatype' near the word CLOBFLD.
    Please Help me out.
    Regards,
    Gopi
    null

    I presume you want to query based on the contents of the CLOB, right ? If that is true, then you have to create a text index, using Oracle Context and then use "Contains" in the where clause to query. Hope this helps.

  • Two secondary indexes in a where clause

    Hi All,
    Can any one of you let me know wether DB optimizer will use two indexes if given in where clause........
    example : primary index A,B.   secondary C,D,E.
    select ................ where A in ....
                                  B in ....
                                  C in ....
    so iam using all(two) fields of primary index and one field of secondary so will the DB optimizer search for the index blocks or directly the table blocks when it comes to the C field in the where clause......
    Thanks in advance.

    Hello,
    To do it use the WHERE stm in the same order as the secondary stm is on SE11....To check if the index is used go to tcode ST05.
    example
    select * from ztable
    WHERE BUKRS EQ 'BUK1' AND
                 ZFIELD EQ 'BOY'.
    on se11 on the ZTABLE indexes setion must have a secondary index with
    BUKRS and
    ZFIELD.
    BYE!!
    Hope this helps!!
    Gabriel

  • [Solved] Named Bind Variables at Runtime - SQL WHERE clause issue

    Hey 'all,
    I've been having this issue today with a Search page using Named Bind Variables at Runtime for the search parameters for the WHERE clause in the view objects SQL.
    I've got everything working except for a clearing method which I've created so that the user can clear the current WHERE clause from the SQL statment and set it as 1=2 (so that it doesn't do a blind query on load).
    The method can clear and set the WHERE clause to 1=2 only when there is already one there.
    Below are the methods: (located in my view object class)
    public void findInvoiceById(Number invoiceId){
        setWhereClause("invoice_id = :P_INVOICE_ID");
        defineNamedWhereClauseParam("P_INVOICE_ID",null,null);
        setNamedWhereClauseParam("P_INVOICE_ID",invoiceId);
        executeQuery();
    public void clearCriteria(){
        setWhereClause("1=2");
        removeNamedWhereClauseParam("P_INVOICE_ID");
        executeQuery();
    }The error which I get is the following - this happens when the button is pressed twice in a row, or when no query has been passed previously.
    1. JBO-29000: Unexpected exception caught: oracle.jbo.NoDefException, msg=JBO-25058: Definition P_INVOICE_ID of type Variable not found in SupplierInvoicesView1
    2. JBO-25058: Definition P_INVOICE_ID of type Variable not found in SupplierInvoicesView1
    Any help with this would be greatly appreciated!
    Cheers,

    Hi Bonnie,
    we have it working ok, but still feel that there is room for improvement in the design.
    For us the key factors are:
    Pages based on the same view object that can be queried multiple ways.
    We don't want to put design time bind variables in because it limits the use of the VO
    We don't wan't multiple VO's with different where clauses.
    The page is displaying the same table columns and fields, but the where clause must be dynamic.
    We only want to query on the search field entered (some of our tables are massive)
    TopLink named queries are really what we are after, but we don't want to forgo all the other ADF BC functionality. The only examples of ViewCriteria in the developer guide had literals in the where clause and no bind variables. The View Criteria may still be an option, but it appeared quite complex compaired to directly adding and removing bind variables at runtime.
    a couple of footnotes:
    the following methods are used to clear the runtime variables prior to reusing the VO (thanks to John Stegman for the pointer on the exception handler):
        public void clearBindVariable(String bindVariableName){
            try
                removeNamedWhereClauseParam(bindVariableName);
            catch (NoDefException e)
        public void clearBindVariables(){
            clearBindVariable("P_INVOICE_ID");
            clearBindVariable("P_INVOICE_NUM");
            clearBindVariable("P_SUPPLIER_NAME");
            clearBindVariable("P_INVOICE_DATE_FROM");
            clearBindVariable("P_INVOICE_DATE_TO");
            clearBindVariable("P_SUPPLIER_NUMBER");
        }We are using 1=1 and 1=2 in the where clause to supress blind querying. 1=2 is applied when ever we are not explicitely searching for something. We had a problem with using the refresh condition ${adfFacesContext.postback == true} which I posted about here:
    executeQuery called twice using ${adfFacesContext.postback == true}
    Would still gladly hear other ideas on a better reuse design.
    regards,
    Brenden

  • Query Builder won't apply chosen date to the where clause

    Does anybody know why when I chose a date field, in the where clause, when using Query Builder, it won't actually write the chosen date to the actual query?
    If I select the "View Query" tab, no date shows up. Also if I press the "Run Report" button in the "View Result" tab, I get this error:
    "An error was encountered performing requested operation: ORA-00936: missing expression"
    This is because actual date data is missing.
    After I hit the "Apply" button, I have to manually type the date data.
    I thought this was a bug of the previous version, but I just installed version 1.5.4 and I have no different result.
    Thanks.

    I just wanted to add my name to the list of people having this issue.
    Oracle Techies, please help.

  • How to set the where clause of a value set on the basis of a form field

    I am using a DFF(Descriptive FlexField), which needs to display the value of a certain column(say columnA) on the basis of the value of another column(say columnB).
    So i have created a value set which points to the table which has both these columns, and the DFF uses this value set. However, the problem is that I have not put any where clause in the value set, because of which i cannot handle the exact fetch returns more than one rows error.
    The query has to be as follows:
    select ColumnA from tbl where ColumnB = [ a form value ];
    What I want to know is how can i get the value of a certain field of a certain block of the form in the above query.
    Edited by: 981615 on Jan 14, 2013 12:48 AM
    Edited by: 981615 on Jan 14, 2013 12:48 AM

    Just have a look over these two statements if it solves your problem
    one time where clause
    Set_Block_Property('BLOCK_NAME',ONETIME_WHERE,your form item);
    dynamic where clause
    set_block_property('BLOCK_NAME'default_where, your form itme)
    you can where clause at run time from any procedure or some triggers

  • Dynamically stating the field name in the WHERE clause

    Hello All,
    Consider the following select statement.
    SELECT kunnr INTO TABLE gt_kunnr
          FROM kna1
          FOR ALL ENTRIES IN gt_table
          WHERE kunnr = gt_table-<b>cust_id</b>.
    Suppose there is a case where I do not know the name of the internal table field
    (say, "cust_id" in the above case) with which comparison is to be done in the WHERE clause. Only at runtime that fieldname is available. So in the WHERE clause can I mention it dynamically?
    I tried using the following.
    lv_fieldname =  'cust_id'.
    SELECT kunnr INTO TABLE gt_kunnr
          FROM kna1
          FOR ALL ENTRIES IN gt_table
          WHERE kunnr = gt_table-<b>(lv_fieldname).</b>
    But this is  giving a syntax error.
    Could anyone suggest an alternate approach?
    Regards
    Indrajit.

    Hi,
    It is fine with Enterprise version but when I am trying to run the following code in Rel 4.6C, I am getting a syntax error.
    TYPES: BEGIN OF ty_wherecond,
             data(72) TYPE c,
           END OF ty_wherecond.
    DATA: gt_itab1 TYPE STANDARD TABLE OF kna1,
          gt_itab2 TYPE STANDARD TABLE OF kna1.
    DATA:  BEGIN OF gt_kunnr OCCURS 0,
                kunnr TYPE kunnr,
           END OF gt_kunnr.
    PERFORM fill_itabs TABLES gt_itab1
                              gt_itab2.
    *&      Form  fill_itabs
          text
         -->P_T_TABLE  text
    FORM fill_itabs  TABLES   p_t_table
                              pt_table_dummy.
      DATA: lv_fieldname(30)   TYPE c VALUE 'pt_table_dummy-kunnr'.
      DATA: lt_wherecond   TYPE STANDARD TABLE OF ty_wherecond,
            lt_condtab     TYPE STANDARD TABLE OF hrcond,
            ls_condtab     TYPE hrcond.
      FIELD-SYMBOLS <fs_wherecond> TYPE ty_wherecond.
      pt_table_dummy[] = p_t_table[].
      CLEAR ls_condtab.
      REFRESH: lt_wherecond[],
               lt_condtab[].
      ls_condtab-field = 'KUNNR'.
      ls_condtab-opera = 'EQ'.
      ls_condtab-low   = lv_fieldname.
      APPEND ls_condtab TO lt_condtab.
      CALL FUNCTION 'RH_DYNAMIC_WHERE_BUILD'
        EXPORTING
          dbtable         = space " can be empty
        TABLES
          condtab         = lt_condtab
          where_clause    = lt_wherecond
        EXCEPTIONS
          empty_condtab   = 01
          no_db_field     = 02
          unknown_db      = 03
          wrong_condition = 04.
      LOOP AT lt_wherecond ASSIGNING <fs_wherecond>.
        REPLACE '''' WITH '' INTO <fs_wherecond>-data.
        REPLACE '''' WITH '' INTO <fs_wherecond>-data.
      ENDLOOP.
      SELECT kunnr INTO TABLE gt_kunnr
          FROM kna1
          FOR ALL ENTRIES IN pt_table_dummy
          WHERE (lt_wherecond).
      IF sy-subrc EQ 0.
      ENDIF.
    ENDFORM.                    "fill_itabs
    The syntax error says "The WHERE condition does not refer to the FOR ALL ENTRIES table".
    Even after using the FM 'RH_DYNAMIC_WHERE_BUILD' as suggested by you, the syntax error is coming.
    Could you please suggest how to ignore this?
    Regards
    Indrajit.

  • Queryeditor using fields more than once in where clause not possible?

    I have to create a select query with a WHERE clause using a field multiple times.
    I can't get this to work. For example:
    SELECT ALL
      EMSDTALIB.EMSPPA.PAIDNR,
      EMSDTALIB.EMSPPA.PANAAM,
      EMSDTALIB.EMSPPA.PAVLTR,
      EMSDTALIB.EMSPPA.PATITL,
      EMSDTALIB.EMSPPA.PAADRS,
      EMSDTALIB.EMSPPA.PAHSNR,
      EMSDTALIB.EMSPPA.PAHSNT,
      EMSDTALIB.EMSPPA.PAPCA1
    FROM EMSDTALIB.EMSPPA
    WHERE EMSDTALIB.EMSPPA.PABEDR=1 AND EMSDTALIB.EMSPPA.PADTUD=0 AND
      (EMSDTALIB.EMSPPA.PADVBD='001' OR EMSDTALIB.EMSPPA.PADVBD='003' OR EMSDTALIB.EMSPPA.PADVBD='006')How do I get this to work?
    Regards,
    Roland

    Hi Roland, Luca, ICON_SS,
    I just tried similar queries using the latest release bits and it works fine.
    My Queries that worked fine are :
    SELECT ALL DASUSR1.PERSON.PERSONID, DASUSR1.PERSON.NAME, DASUSR1.PERSON.JOBTITLE, DASUSR1.PERSON.FREQUENTFLYER
    FROM DASUSR1.PERSON
    WHERE ( DASUSR1.PERSON.NAME='Able, Tony' OR NAME='Black, John' )
    SELECT ALL DASUSR1.PERSON.PERSONID, DASUSR1.PERSON.NAME, DASUSR1.PERSON.JOBTITLE, DASUSR1.PERSON.FREQUENTFLYER
    FROM DASUSR1.PERSON
    WHERE ( DASUSR1.PERSON.PERSONID=1 OR PERSONID=2 OR PERSONID=3)
    I would suggest you to Download & Install latest Creator bits released 9/27/2004, if not already done.
    Appreciate your valuable feedback,
    Sakthi

  • How Can I Extract a Substring in WHERE Clause of CFQUERY ?

    Is it possible to extract a substring in the WHERE clause of either <CFQUERY> or in a Query of Queries?  I am trying to use the following query to find all email addresses with the domain "comcast.net" (i.e. everything after the "@" in the email address).  I am querying an MS-Access database table.
    <cfquery name="test" datasource="membership">
          SELECT email_address
          FROM tblMembers
          WHERE MID(email_address, INSTR(email_address, '@') + 1) = 'comcast.net'
    </cfquery>
    If I attempt this as a query, I get the error message "[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression."
    If I attempt it as a QoQ, I get the error message 'Encountered "MID ( email1 ,. Incorrect conditional expression, Expected one of [like|null|between|in|comparison] condition,'.
    I would be very grateful for any help on finding something that works!  Thanks for your help!

    Couldn't you do a LIKE in the where clause instead:
    SELECT email_address
    FROM tblMembers
    WHERE email_address LIKE '%@comcast.net'
    That should get you the addresses you are looking for.
    -Carl V.

Maybe you are looking for

  • Why will video podcasts no longer sync to my ipod?

    I used to be able to watch video podcasts on my iPod nano (5th generation).  Then, one day it stopped syncing them to the iPod.  I think an error message came up saying that my iPod didn't support the videos anymore (something about HD).  I assumed t

  • How to create a 'video-less' audio album in FCPX?

    Hello to all! I need guidance in this matter. I have with me about 5 audio albums and am on the job of making music videos of them. I have made videos of a few of them and have posted them to YouTube. Finding the going slow, I am contemplating doing

  • 1/4 screen playback with full screen video?

    I apologize if this has been addressed before, a search of the first 50 pages as well as the Search Forum didn't turn up anything on this. When attempting to play back full screen video (720x480 or 640x480) the upper left quarter of the window displa

  • Video comparison between the 6270 and 6280

    What is the maximum video resolution of the 6270? Does it have 640 x 460 resolution that the 6280 has? And for anyone who has handled both, is there much difference between the two for operating systems, camera quality, memory and the lot? Grateful i

  • Event 2000. hpsa_servi​ce.exe

    HP Error ID: -2146233088   at HP.ActiveCheckLocalMode.SessionManager.ActiveCheck​Manager.InitRegItem()    at HP.ActiveCheckLocalMode.SessionManager.ActiveCheck​Manager..ctor()    at HP.SupportFramework.Service.ACLM.AssetAgent.Execut​eAssetAgent(Boole