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}

Similar Messages

  • Create Index to use Like Clause

    Hi All,
    I want one of my query to use a index which runs with a LIKE Clause. I have not done that before but i have heard and seen through forums that its possible to create indexes for a column with Like Clause using function based index.
    Function
    Request the forum users to achieve my objective. Let me list down what i have done.
    Function
    CREATE OR REPLACE FUNCTION RND_LIKE(P_NO IN VARCHAR2)
    RETURN VARCHAR2 IS
    RESULT VARCHAR2(240);
    BEGIN
    RETURN P_NO||'%';
    END RND_LIKE;
    SELECT ENAME FROM EMP WHERE ENAME LIKE RND_LIKE('A')
    Here based on this function i want to create a function based index and force the same to my query. Request the forum users to help me out in this.
    Thanks
    Edited by: ramarun on Dec 18, 2009 9:26 PM

    In the case you had there , Oracle would use an index on ename in a query if you were to type A% in the ename item on a Form. You wouldn't need a function index for that.
    Here's the link to the documentation to create a function based index http://download-uk.oracle.com/docs/cd/B28359_01/server.111/b28310/indexes003.htm#i1006674

  • Using Like Clause in Prepared Statement

    Hi,
    I want to use LIKE clause in prepared statement. This is not returning any record.
    This is the query. Please help me in this.
    SELECT EMPLYR_GRP,EMPLYR_GRP_NAME FROM EMPLOYER_GROUP WHERE EMPLYR_GRP_NAME LIKE ? AND EMPLYR_GRP = ?
    This is giving Oracle SQL Error.
    SELECT EMPLYR_GRP,EMPLYR_GRP_NAME FROM EMPLOYER_GROUP WHERE EMPLYR_GRP_NAME LIKE %?% AND EMPLYR_GRP = ?

    The first variant should work just fine as long as you use stmt.setString(1, '%' + pattern + '%') to set the parameter. The second query is just plain wrong.
    Alin.

  • Using like with select clause

    Hi experts,
    I have a problem where i feel i should catch filtered resultset on to my internal table and i feel using LIKE.
    But if i use LIKE '%AMIT%'
    will it store
    AMIT
    amit
    Amit  ie all possible combination irrespectin of any case ?
    Will it be case insenstive or not ?

    HI,
    using like in select is case sensitive.
    do like this for ignoring the case.
    TABLES:mara.
    SELECT * from mara.
      IF mara-matnr cp 'm*'.
        WRITE:/ mara-matnr.
      ENDIF.
    ENDSELECT.
    rgds,
    bharat.

  • 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 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.

  • How can you add a where clause using "OR" with applied ViewCriteria?

    [JDeveloper 10.1.3 SU4]
    [JHeadstart 10.1.3 build 78]
    I am using JHeadstart, but have a question probably more in the ADF area. On the JHeadstart forum I asked:
    "I am overriding JhsApplicationModule's advancedSearch in order to be able to search in childtables. I created transient attributes, display those in advanced search and in the overridden method I check if any of these are filled by the user and create a where clause like 'EXISTS (SELECT 1 FROM <childtable> WHERE <column in childtable> = <column in EO's table> AND <another column in childtable> LIKE '<value supplied by user>)'. I add this whereclause using ViewObject.setWhereClause.
    So far so good and it works. However, if the user selects 'Result matches any criteria', combining setWhereClause and the normal advancedSearch QueryByExample implementation using ViewCriteriaRow do not provide the desired result, since the ViewCriteria and the setWhereClause are AND-ed together, which is fine if the user selects the (default) "Results match all criteria" (everything is AND-ed) but not the "Result matches any criteria", since then every criterium is OR-ed together, except for the setwhereclause criteria and the set of ViewCriteriaRows, they are AND-ed.
    I looked if I could specify that a WhereClause will be OR-ed to existing applied ViewCriteria, but no luck. Do I have to rewrite also advancedSearch's ViewCriteria implementation and write an entire setWhereClause implementation to be able to "OR" every criterium? Or any other suggestions? Can I look at the entire Where clause and rewrite it (after applyCriteria and setWhereClause are called on the VO)?
    Toine"
    Sandra Muller (JHeadstart Team) told me today: "This sounds like a JDeveloper/ADF issue that is not related to JHeadstart. The question is: how can you add a where clause using "OR" if there are already one or more ViewCriteria applied?
    To simplify the test case, you could create a simple ADF BC test client class in a test Model project without JHeadstart (in the test class, use bc4jclient + Ctrl-Enter), in which you first apply a few ViewCriteriaRows to a View Object and also add a where clause.
    Can you please log a TAR at MetaLink ( http://metalink.oracle.com/ ), or ask this question at the JDeveloper forum at http://otn.oracle.com/discussionforums/jdev.html ? (This what I am doing now ;-))
    Thanks,
    Sandra Muller
    JHeadstart Team
    Oracle Consulting"
    Anyone knowing the answer or am I asking for an enhancement?
    Toine

    Hi,
    Can you SET your whereclause as follows ?
    ('Y' = <isAnd>
    and EXISTS (SELECT 1 FROM <childtable> WHERE <column in childtable> = <column in EO's table> AND <another column in childtable> LIKE '<value supplied by user>))
    OR ('N' = <isAnd>
    AND EXISTS (SELECT 1 FROM <childtable> WHERE <column in childtable> = <column in EO's table> OR <another column in childtable> LIKE '<value supplied by user>))
    )

  • Sql query using LIKE is very slow

    Hi,
    I am running SQL query with LIKE on two table with more than two million records on oracle 10g and sun solaris OS. Does anybody have any idea or alternative to improve this query?
    it will never use index because i m using LIKE '%xyz%'. I Have posted query below
    PROCEDURE order_search
    v_search_type_in IN VARCHAR2
    ,v_search_value1_in IN VARCHAR2 DEFAULT 'NONE'
    ,v_search_value2_in IN VARCHAR2 DEFAULT 'NONE'
    ,v_group_id_in IN bcf_groups.group_id%TYPE DEFAULT 0
    ,v_open_in IN NUMBER DEFAULT 0
    ,v_requested_in IN NUMBER DEFAULT 0
    ,v_cancelled_in IN NUMBER DEFAULT 0
    ,v_closed_in IN NUMBER DEFAULT 0
    ,v_employee_id_in IN sxweb00.customer.customer_id%TYPE DEFAULT 0
    ,outcursor IN OUT FulfillmentCurType
    IS
    v_status_code NUMBER;
    v_upper_search_value1 VARCHAR2(500);
    v_lower_search_value1 VARCHAR2(500);
    v_open_status VARCHAR2(10);
    v_closed_status VARCHAR2(10);
    v_cancelled_status VARCHAR2(10);
    v_requested_status VARCHAR2(10);
    v_group_for_search bcf_groups.group_id%TYPE;
    v_sql_select VARCHAR2(4000);
    v_sql_from VARCHAR2(4000);
    v_sql_where VARCHAR2(4000);
    v_sql_order_by VARCHAR2(4000);
    v_group_where VARCHAR2(100);
    v_status_where VARCHAR2(500);
    BEGIN
    IF v_open_in = 1 THEN
    v_open_status := 'OPEN';
    END IF;
    IF v_closed_in = 1 THEN
    v_closed_status := 'CLOSED';
    END IF;
    IF v_cancelled_in = 1 THEN
    v_cancelled_status := 'CANCELLED';
    END IF;
    IF v_requested_in = 1 THEN
    v_requested_status := 'REQUESTED';
    END IF;
    IF UPPER(v_search_type_in) = 'GROUP'
    THEN
    v_group_for_search := v_search_value1_in;
    ELSE
    v_group_for_search := v_group_id_in;
    END IF;
    -- This is the select statement used for all search types
    v_sql_select := ' '
    || 'po.order_id order_id '
    || ',decode('||v_group_id_in||',4,substr(bcf_locator.get_first_location(po.order_id,'||v_group_id_in||'),3),null) first_location '
    || ',TO_CHAR(po.order_date, ''mm/dd/yyyy'') order_date '
    || ',' || v_group_for_search || ' group_id '
    || ',TRIM(TO_CHAR(bcf_fulfillment.get_shipping_total(po.order_id,' || v_group_for_search || ') + bcf_fulfillment.get_tax_total(po.order_id,' || v_group_for_search || ') + bcf_fulfillment.get_subtotal(po.order_id,' || v_group_for_search || ') ,''$999,999,999,999,999,990.99'')) total '
    || ',bcf_fulfillment.get_billing_name (po.customer_id) billing_name '
    || ',bcf_fulfillment.get_open_and_assigned_count(po.order_id,' || v_group_for_search || ') open_and_assigned_count '
    || ',bcf_fulfillment.get_divisions(po.order_id,' || v_group_for_search || ') divisions '
    || ',bcf_fulfillment.get_division_count (po.order_id,' || v_group_for_search || ' ) division_count '
    || ',bcf_fulfillment.get_picker_list (po.order_id,' || v_group_for_search || ') picker_name '
    || ',bcf_fulfillment.get_picker_count (po.order_id,' || v_group_for_search || ') picker_count '
    || ',bcf_fulfillment.get_order_status(po.order_id,' || v_group_for_search || ') order_status '
    || ',po.customer_id customer_id '
    -- IF there is only one unique picker then that means there are no unassigned or NULL pickers
    -- therefore by default the checkbox should not be selected else the count picker_count is
    -- 0 or > 1 meaning that at least one line item has an unassigned employee_id and by default
    -- the checkbox should be selected
    || ',DECODE(bcf_fulfillment.get_picker_count(po.order_id,' || v_group_for_search || '),1 ,0,1) print_cb '
    || ',bcf_fulfillment.get_fulfillment_codes(po.order_id,' || v_group_for_search || ') fulfillment_types '
    || ',bcf_fulfillment.has_group_been_reassigned(po.order_id,' || v_group_for_search || ') group_reassigned_flag '
    || ',bcf_fulfillment.get_chain_codes(po.order_id,' || v_group_for_search || ') chain_codes '
    || ',po.status_id order_status_id '
    || ',bcf_fulfillment.get_viewed_by_picker_flag(po.order_id,' || v_group_for_search || ') viewed_by_picker_flag '
    || ',bcf_fulfillment.get_picker_list (po.order_id,' || v_group_for_search || ', ''N'') pickers_without_unassigned '
    || ',bcf_fulfillment.get_group_list (po.order_id) group_list '
    || ',bcf_fulfillment.get_line_item_count(po.order_id,' || v_group_for_search || ') line_item_count '
    || ',bcf_fulfillment.get_shipping_priority(po.order_id,' || v_group_for_search || ') shipping_priority'
    -- Anna wants all users to know and always wants to know no matter what the status of the auth or order
    || ',(SELECT decode(count(*),0,''N'',''Y'') FROM bcf_payment WHERE ics_rflag = ''DAVSNO'' AND order_id = po.order_id AND status_code IN (''ATH2'',''FUL2'',''CPT0'',''CPT2'')) avs_failed'
    || ',trunc(po.order_date) date_for_sort'
    -- When we need to look at all orders then the v_group_for_search will be zero i.e. customer service rep
    IF v_group_for_search = 0 THEN
    -- This is the core tables used by most search types
    v_sql_from := ' '
    || 'FROM product_order po'
    -- || ',bcf_lookup lu'
    -- This is the core table join needed for most search types
    v_sql_where := ' '
    || 'WHERE 1 = 1 '
    -- No orders will be looked at for fulfillment purposes that occurred before the minimum
    -- shipping cost functionality was added
    -- || 'AND po.order_date >= lu.implement_date '
    || 'AND po.order_date >= (SELECT min(implement_date) FROM bcf_lookup) '
    || 'AND po.submitted_flag = 1 '
    || 'AND po.channel_code = ''BCF'' '
    -- When we are looking at all orders then we are not going to restrict it by group
    v_group_where := ' ';
    -- This is used where the search type requires searching by the Open, Closed, and Cancelled status.
    -- We are binding the three status variables so that they can be cached in Oracle and not need to be parsed after
    -- the first search of a search type is done.
    v_status_where := ' '
    || 'AND bcf_fulfillment.get_order_status(po.order_id,' || v_group_for_search|| ') '
    || 'IN (:v_open_status, :v_requested_status, :v_cancelled_status, :v_closed_status) '
    ELSE
    -- This is the core tables used by most search types
    v_sql_from := ' '
    || 'FROM product_order po'
    || ',bcf_product_order_groups pog '
    -- This is the core table join needed for most search types
    v_sql_where := ' '
    || 'WHERE 1 = 1 '
    || 'AND po.order_id = pog.order_id '
    || 'AND po.channel_code = ''BCF'' '
    -- This is used only where the search type requires searching by a group.
    v_group_where := ' '
    || 'AND pog.group_id = ' || v_group_for_search
    -- This is used where the search type requires searching by the Open, Closed, and Cancelled status.
    -- We are binding the three status variables so that they can be cached in Oracle and not need to be parsed after
    -- the first search of a search type is done.
    v_status_where := ' '
    || 'AND pog.dn_status IN (:v_open_status, :v_requested_status, :v_cancelled_status, :v_closed_status) '
    END IF;
    -- If an employee_id is provided then we need to add in a where clause so that only orders that belong to that
    -- employee are pulled
    IF v_employee_id_in > 0
    THEN
    v_sql_where := v_sql_where
    || 'AND pog.dn_employee_id = ' || TO_CHAR(v_employee_id_in) || ' '
    END IF;
    IF v_group_id_in = get_group_fulfillment_center1
    THEN
    v_sql_order_by := 'ORDER BY '
    || 'bcf_fulfillment.get_division_count (po.order_id,' || v_group_for_search || ') '
    || ',bcf_fulfillment.get_divisions(po.order_id,' || v_group_for_search || ') '
    || ',po.order_id '
    ELSIF v_group_id_in = c_GROUP_FULFILLMENT_CENTER_212
    THEN
    v_sql_order_by := 'ORDER BY '
    || 'bcf_fulfillment.get_shipping_priority(po.order_id,' || v_group_for_search || ') DESC'
    || ',TRUNC(po.order_date)'
    || ',bcf_fulfillment.get_line_item_count(po.order_id,' || v_group_for_search || ')'
    || ',decode('||v_group_id_in||',4,substr(bcf_locator.get_first_location(po.order_id,'||v_group_id_in||'),3),null)'
    || ',po.order_id'
    ELSE
    v_sql_order_by := 'ORDER BY '
    || ' bcf_fulfillment.get_shipping_priority(po.order_id,' || v_group_for_search || ') DESC'
    || ',chain_codes DESC'
    || ',po.order_id '
    END IF;
    IF UPPER(v_search_type_in) = 'ORDERNUMBER'
    THEN
    v_sql_where := v_sql_where || v_group_where
    || 'AND po.order_id = :v_search_value1_in '
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT ' || v_sql_select || v_sql_from || v_sql_where
    USING v_search_value1_in;
    ELSIF UPPER(v_search_type_in) = 'STATUSONLY'
    THEN
    v_sql_where := v_sql_where || v_group_where || v_status_where
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT ' || v_sql_select || v_sql_from || v_sql_where || v_sql_order_by
    USING v_open_status, v_requested_status, v_cancelled_status, v_closed_status;
    ELSIF UPPER(v_search_type_in) = 'BILLINGNAME'
    THEN
    v_upper_search_value1 := UPPER(v_search_value1_in);
    v_sql_where := v_sql_where || ' ' || v_group_where
    || 'AND po.upper_billing_name LIKE ''%'' || :v_upper_search_value1 || ''%'' '
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT ' || v_sql_select || v_sql_from || v_sql_where || v_sql_order_by
    USING v_upper_search_value1;
    ELSIF UPPER(v_search_type_in) = 'GROUP'
    THEN
    IF v_search_value1_in = '0' -- Unassigned
    THEN
    v_sql_from := v_sql_from || ' ,product_order_detail_actv_v pod ';
    v_sql_where := v_sql_where || ' ' || v_status_where
    || 'AND po.order_id = pod.order_id '
    || 'AND pod.group_id IS NULL '
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT DISTINCT ' || v_sql_select || v_sql_from || v_sql_where || v_sql_order_by
    USING v_open_status, v_requested_status, v_cancelled_status, v_closed_status;
    ELSE
    v_sql_where := v_sql_where || ' ' || v_status_where
    || 'AND pog.group_id = :v_group_for_search '
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT ' || v_sql_select || v_sql_from || v_sql_where || v_sql_order_by
    USING v_open_status, v_requested_status, v_cancelled_status, v_closed_status, v_group_for_search;
    END IF;
    ELSIF UPPER(v_search_type_in) = 'SHIPPINGNAME'
    THEN
    v_upper_search_value1 := UPPER(v_search_value1_in);
    v_sql_where := v_sql_where || ' ' || v_group_where
    || 'AND po.upper_shipping_name LIKE ''%'' || :v_upper_search_value1 || ''%'' '
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT ' || v_sql_select || v_sql_from || v_sql_where || v_sql_order_by
    USING v_upper_search_value1;
    ELSIF UPPER(v_search_type_in) = 'USERNAME'
    THEN
    v_lower_search_value1 := LOWER(v_search_value1_in);
    v_sql_from := v_sql_from || ' ,sxweb01.customer c ';
    v_sql_where := v_sql_where || ' ' || v_group_where
    || 'AND po.customer_id = c.customer_id '
    || 'AND c.username LIKE ''%'' || :v_lower_search_value1 || ''%'' '
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT ' || v_sql_select || v_sql_from || v_sql_where || v_sql_order_by
    USING v_lower_search_value1;
    ELSIF UPPER(v_search_type_in) = 'BILLINGADDRESS1'
    THEN
    v_upper_search_value1 := UPPER(v_search_value1_in);
    v_sql_from := v_sql_from || ' ,order_payment op '
    || ' ,credit_card cc '
    || ' ,om_address oma '
    v_sql_where := v_sql_where || ' ' || v_group_where
    || 'AND po.order_id = op.business_object_id '
    || 'AND op.business_object_type = ''ORDR'' '
    || 'AND op.payment_method = ''CRCD'' '
    || 'AND op.payment_method_id = cc.credit_card_id '
    || 'AND cc.address_id = oma.address_id '
    || 'AND UPPER(oma.address1) LIKE ''%'' || :v_upper_search_value1 || ''%'' '
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT ' || v_sql_select || v_sql_from || v_sql_where || v_sql_order_by
    USING v_upper_search_value1;
    ELSIF UPPER(v_search_type_in) = 'SHIPPINGADDRESS1'
    THEN
    v_upper_search_value1 := UPPER(v_search_value1_in);
    v_sql_from := v_sql_from || ' ,shipping_info si '
    || ' ,om_address oma '
    v_sql_where := v_sql_where || ' ' || v_group_where
    || 'AND po.order_id = si.order_id '
    || 'AND si.ship_to_address_id = oma.address_id '
    || 'AND UPPER(oma.address1) LIKE ''%'' || :v_upper_search_value1 || ''%'' '
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT ' || v_sql_select || v_sql_from || v_sql_where || v_sql_order_by
    USING v_upper_search_value1;
    ELSIF UPPER(v_search_type_in) = 'BILLINGPHONE'
    THEN
    v_sql_from := v_sql_from || ' ,order_payment op '
    || ' ,credit_card cc '
    v_sql_where := v_sql_where || ' ' || v_group_where
    || 'AND po.order_id = op.business_object_id '
    || 'AND op.business_object_type = ''ORDR'' '
    || 'AND op.payment_method = ''CRCD'' '
    || 'AND op.payment_method_id = cc.credit_card_id '
    || 'AND cc.home_phone = :v_search_value1_in '
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT ' || v_sql_select || v_sql_from || v_sql_where || v_sql_order_by
    USING v_search_value1_in;
    ELSIF UPPER(v_search_type_in) = 'SHIPPINGPHONE'
    THEN
    v_sql_from := v_sql_from || ' ,shipping_info si '
    v_sql_where := v_sql_where || ' ' || v_group_where
    || 'AND po.order_id = si.order_id '
    || 'AND si.ship_phone = :v_search_value1_in '
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT ' || v_sql_select || v_sql_from || v_sql_where || v_sql_order_by
    USING v_search_value1_in;
    ELSIF UPPER(v_search_type_in) = 'CREDITCARDNUMBER'
    THEN
    v_sql_from := v_sql_from || ' ,order_payment op '
    || ' ,credit_card cc '
    v_sql_where := v_sql_where || ' ' || v_group_where
    || 'AND po.order_id = op.business_object_id '
    || 'AND op.business_object_type = ''ORDR'' '
    || 'AND op.payment_method = ''CRCD'' '
    || 'AND op.payment_method_id = cc.credit_card_id '
    || 'AND cc.credit_card_number = :v_search_value1_in '
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT ' || v_sql_select || v_sql_from || v_sql_where || v_sql_order_by
    USING v_search_value1_in;
    ELSIF UPPER(v_search_type_in) = 'PONUMBER'
    THEN
    v_sql_from := ' '
    || 'FROM ' || ' product_order_detail_actv_v pod ,' || SUBSTR(v_sql_from, 6);
    v_sql_where := v_sql_where || v_group_where
    || 'AND pod.po_no = :v_search_value1_in '
    || 'AND po.order_id = pod.order_id '
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT /*+ ORDERED */ DISTINCT ' || v_sql_select || v_sql_from || v_sql_where
    USING v_search_value1_in;
    ELSIF UPPER(v_search_type_in) = 'USERASSIGNED'
    THEN
    IF v_search_value1_in = '0' -- 'Unassigned'
    THEN
    v_sql_where := v_sql_where || ' ' || v_group_where || ' ' || v_status_where
    || 'AND pog.unassigned_flag = ''Y'' '
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT ' || v_sql_select || v_sql_from || v_sql_where || v_sql_order_by
    USING v_open_status, v_requested_status, v_cancelled_status, v_closed_status;
    ELSE
    v_sql_where := v_sql_where || ' ' || v_group_where || ' ' || v_status_where
    || 'AND pog.dn_employee_id = :v_search_value1_in '
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT ' || v_sql_select || v_sql_from || v_sql_where || v_sql_order_by
    USING v_open_status, v_requested_status, v_cancelled_status, v_closed_status, v_search_value1_in;
    END IF;
    ELSIF UPPER(v_search_type_in) = 'ORDERDATE'
    THEN
    v_sql_where := v_sql_where || ' ' || v_group_where || ' ' || v_status_where
    || 'AND po.order_date BETWEEN TO_DATE( :v_search_value1_in, ''MON DD YYYY HH24:MI:SS'') AND TO_DATE( :v_search_value2_in ,''MON DD YYYY HH24:MI:SS'') '
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT ' || v_sql_select || v_sql_from || v_sql_where || v_sql_order_by
    USING v_open_status, v_requested_status, v_cancelled_status, v_closed_status, v_search_value1_in, v_search_value2_in;
    ELSIF UPPER(v_search_type_in) = 'PRINTJOB'
    THEN
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT ' || v_sql_select
    || ' '
    || 'FROM product_order po '
    || ' ,bcf_print_jobs pj '
    || 'WHERE 1 = 1 '
    || 'AND pj.order_id = po.order_id '
    || 'AND pj.username = :v_search_value1_in '
    || 'AND pj.create_date = TO_DATE( :v_search_value2_in,''MON DD YYYY HH24:MI:SS'') '
    || v_sql_order_by
    USING v_search_value1_in, v_search_value2_in;
    ELSIF UPPER(v_search_type_in) = 'FULFILLMENTTYPE'
    THEN
    v_sql_from := v_sql_from || ' ,product_order_detail_actv_v pod ';
    v_sql_where := v_sql_where || ' ' || v_group_where || ' ' || v_status_where
    || 'AND pod.order_id = po.order_id '
    -- Because we have to drill down the the POD level
    -- we now need to ensure the pod records match on group
    || 'AND pod.group_id = ' || v_group_for_search
    -- We curr. have 3 fufillment types FC165, FC212, FCBABY
    -- so substr on 1st char works for Garry
    || 'AND UPPER(SUBSTR(pod.fulfillment_type,1,1)) = UPPER(:v_search_value1_in) '
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT DISTINCT ' || v_sql_select || v_sql_from || v_sql_where || v_sql_order_by
    USING v_open_status, v_requested_status, v_cancelled_status, v_closed_status, v_search_value1_in;
    ELSIF UPPER(v_search_type_in) = 'INSUFFICIENTAUTHORIZATION'
    THEN
    v_sql_where := v_sql_where
    || 'AND bcf_get_authorization_amount(po.order_id) > 0'
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT ' || v_sql_select || v_sql_from || v_sql_where || v_sql_order_by;
    END IF;
    END order_search;
    Thanks
    V
    Edited by: vishal patel on Oct 23, 2008 3:59 PM

    PROCEDURE order_search
    v_search_type_in IN VARCHAR2
    ,v_search_value1_in IN VARCHAR2 DEFAULT 'NONE'
    ,v_search_value2_in IN VARCHAR2 DEFAULT 'NONE'
    ,v_group_id_in IN bcf_groups.group_id%TYPE DEFAULT 0
    ,v_open_in IN NUMBER DEFAULT 0
    ,v_requested_in IN NUMBER DEFAULT 0
    ,v_cancelled_in IN NUMBER DEFAULT 0
    ,v_closed_in IN NUMBER DEFAULT 0
    ,v_employee_id_in IN sxweb00.customer.customer_id%TYPE DEFAULT 0
    ,outcursor IN OUT FulfillmentCurType
    IS
    v_status_code NUMBER;
    v_upper_search_value1 VARCHAR2(500);
    v_lower_search_value1 VARCHAR2(500);
    v_open_status VARCHAR2(10);
    v_closed_status VARCHAR2(10);
    v_cancelled_status VARCHAR2(10);
    v_requested_status VARCHAR2(10);
    v_group_for_search bcf_groups.group_id%TYPE;
    v_sql_select VARCHAR2(4000);
    v_sql_from VARCHAR2(4000);
    v_sql_where VARCHAR2(4000);
    v_sql_order_by VARCHAR2(4000);
    v_group_where VARCHAR2(100);
    v_status_where VARCHAR2(500);
    BEGIN
    IF v_open_in = 1 THEN
    v_open_status := 'OPEN';
    END IF;
    IF v_closed_in = 1 THEN
    v_closed_status := 'CLOSED';
    END IF;
    IF v_cancelled_in = 1 THEN
    v_cancelled_status := 'CANCELLED';
    END IF;
    IF v_requested_in = 1 THEN
    v_requested_status := 'REQUESTED';
    END IF;
    IF UPPER(v_search_type_in) = 'GROUP'
    THEN
    v_group_for_search := v_search_value1_in;
    ELSE
    v_group_for_search := v_group_id_in;
    END IF;
    -- This is the select statement used for all search types
    v_sql_select := ' '
    || 'po.order_id order_id '
    || ',decode('||v_group_id_in||',4,substr(bcf_locator.get_first_location(po.order_id,'||v_group_id_in||'),3),null) first_location '
    || ',TO_CHAR(po.order_date, ''mm/dd/yyyy'') order_date '
    || ',' || v_group_for_search || ' group_id '
    || ',TRIM(TO_CHAR(bcf_fulfillment.get_shipping_total(po.order_id,' || v_group_for_search || ') + bcf_fulfillment.get_tax_total(po.order_id,' || v_group_for_search || ') + bcf_fulfillment.get_subtotal(po.order_id,' || v_group_for_search || ') ,''$999,999,999,999,999,990.99'')) total '
    || ',bcf_fulfillment.get_billing_name (po.customer_id) billing_name '
    || ',bcf_fulfillment.get_open_and_assigned_count(po.order_id,' || v_group_for_search || ') open_and_assigned_count '
    || ',bcf_fulfillment.get_divisions(po.order_id,' || v_group_for_search || ') divisions '
    || ',bcf_fulfillment.get_division_count (po.order_id,' || v_group_for_search || ' ) division_count '
    || ',bcf_fulfillment.get_picker_list (po.order_id,' || v_group_for_search || ') picker_name '
    || ',bcf_fulfillment.get_picker_count (po.order_id,' || v_group_for_search || ') picker_count '
    || ',bcf_fulfillment.get_order_status(po.order_id,' || v_group_for_search || ') order_status '
    || ',po.customer_id customer_id '
    -- IF there is only one unique picker then that means there are no unassigned or NULL pickers
    -- therefore by default the checkbox should not be selected else the count picker_count is
    -- 0 or > 1 meaning that at least one line item has an unassigned employee_id and by default
    -- the checkbox should be selected
    || ',DECODE(bcf_fulfillment.get_picker_count(po.order_id,' || v_group_for_search || '),1 ,0,1) print_cb '
    || ',bcf_fulfillment.get_fulfillment_codes(po.order_id,' || v_group_for_search || ') fulfillment_types '
    || ',bcf_fulfillment.has_group_been_reassigned(po.order_id,' || v_group_for_search || ') group_reassigned_flag '
    || ',bcf_fulfillment.get_chain_codes(po.order_id,' || v_group_for_search || ') chain_codes '
    || ',po.status_id order_status_id '
    || ',bcf_fulfillment.get_viewed_by_picker_flag(po.order_id,' || v_group_for_search || ') viewed_by_picker_flag '
    || ',bcf_fulfillment.get_picker_list (po.order_id,' || v_group_for_search || ', ''N'') pickers_without_unassigned '
    || ',bcf_fulfillment.get_group_list (po.order_id) group_list '
    || ',bcf_fulfillment.get_line_item_count(po.order_id,' || v_group_for_search || ') line_item_count '
    || ',bcf_fulfillment.get_shipping_priority(po.order_id,' || v_group_for_search || ') shipping_priority'
    -- Anna wants all users to know and always wants to know no matter what the status of the auth or order
    || ',(SELECT decode(count(*),0,''N'',''Y'') FROM bcf_payment WHERE ics_rflag = ''DAVSNO'' AND order_id = po.order_id AND status_code IN (''ATH2'',''FUL2'',''CPT0'',''CPT2'')) avs_failed'
    || ',trunc(po.order_date) date_for_sort'
    -- When we need to look at all orders then the v_group_for_search will be zero i.e. customer service rep
    IF v_group_for_search = 0 THEN
    -- This is the core tables used by most search types
    v_sql_from := ' '
    || 'FROM product_order po'
    -- || ',bcf_lookup lu'
    -- This is the core table join needed for most search types
    v_sql_where := ' '
    || 'WHERE 1 = 1 '
    -- No orders will be looked at for fulfillment purposes that occurred before the minimum
    -- shipping cost functionality was added
    -- || 'AND po.order_date >= lu.implement_date '
    || 'AND po.order_date >= (SELECT min(implement_date) FROM bcf_lookup) '
    || 'AND po.submitted_flag = 1 '
    || 'AND po.channel_code = ''BCF'' '
    -- When we are looking at all orders then we are not going to restrict it by group
    v_group_where := ' ';
    -- This is used where the search type requires searching by the Open, Closed, and Cancelled status.
    -- We are binding the three status variables so that they can be cached in Oracle and not need to be parsed after
    -- the first search of a search type is done.
    v_status_where := ' '
    || 'AND bcf_fulfillment.get_order_status(po.order_id,' || v_group_for_search|| ') '
    || 'IN (:v_open_status, :v_requested_status, :v_cancelled_status, :v_closed_status) '
    ELSE
    -- This is the core tables used by most search types
    v_sql_from := ' '
    || 'FROM product_order po'
    || ',bcf_product_order_groups pog '
    -- This is the core table join needed for most search types
    v_sql_where := ' '
    || 'WHERE 1 = 1 '
    || 'AND po.order_id = pog.order_id '
    || 'AND po.channel_code = ''BCF'' '
    -- This is used only where the search type requires searching by a group.
    v_group_where := ' '
    || 'AND pog.group_id = ' || v_group_for_search
    -- This is used where the search type requires searching by the Open, Closed, and Cancelled status.
    -- We are binding the three status variables so that they can be cached in Oracle and not need to be parsed after
    -- the first search of a search type is done.
    v_status_where := ' '
    || 'AND pog.dn_status IN (:v_open_status, :v_requested_status, :v_cancelled_status, :v_closed_status) '
    END IF;
    -- If an employee_id is provided then we need to add in a where clause so that only orders that belong to that
    -- employee are pulled
    IF v_employee_id_in > 0
    THEN
    v_sql_where := v_sql_where
    || 'AND pog.dn_employee_id = ' || TO_CHAR(v_employee_id_in) || ' '
    END IF;
    IF v_group_id_in = get_group_fulfillment_center1
    THEN
    v_sql_order_by := 'ORDER BY '
    || 'bcf_fulfillment.get_division_count (po.order_id,' || v_group_for_search || ') '
    || ',bcf_fulfillment.get_divisions(po.order_id,' || v_group_for_search || ') '
    || ',po.order_id '
    ELSIF v_group_id_in = c_GROUP_FULFILLMENT_CENTER_212
    THEN
    v_sql_order_by := 'ORDER BY '
    || 'bcf_fulfillment.get_shipping_priority(po.order_id,' || v_group_for_search || ') DESC'
    || ',TRUNC(po.order_date)'
    || ',bcf_fulfillment.get_line_item_count(po.order_id,' || v_group_for_search || ')'
    || ',decode('||v_group_id_in||',4,substr(bcf_locator.get_first_location(po.order_id,'||v_group_id_in||'),3),null)'
    || ',po.order_id'
    ELSE
    v_sql_order_by := 'ORDER BY '
    || ' bcf_fulfillment.get_shipping_priority(po.order_id,' || v_group_for_search || ') DESC'
    || ',chain_codes DESC'
    || ',po.order_id '
    END IF;
    IF UPPER(v_search_type_in) = 'ORDERNUMBER'
    THEN
    v_sql_where := v_sql_where || v_group_where
    || 'AND po.order_id = :v_search_value1_in '
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT ' || v_sql_select || v_sql_from || v_sql_where
    USING v_search_value1_in;
    ELSIF UPPER(v_search_type_in) = 'STATUSONLY'
    THEN
    v_sql_where := v_sql_where || v_group_where || v_status_where
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT ' || v_sql_select || v_sql_from || v_sql_where || v_sql_order_by
    USING v_open_status, v_requested_status, v_cancelled_status, v_closed_status;
    ELSIF UPPER(v_search_type_in) = 'BILLINGNAME'
    THEN
    v_upper_search_value1 := UPPER(v_search_value1_in);
    v_sql_where := v_sql_where || ' ' || v_group_where
    || 'AND po.upper_billing_name LIKE ''%'' || :v_upper_search_value1 || ''%'' '
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT ' || v_sql_select || v_sql_from || v_sql_where || v_sql_order_by
    USING v_upper_search_value1;
    ELSIF UPPER(v_search_type_in) = 'GROUP'
    THEN
    IF v_search_value1_in = '0' -- Unassigned
    THEN
    v_sql_from := v_sql_from || ' ,product_order_detail_actv_v pod ';
    v_sql_where := v_sql_where || ' ' || v_status_where
    || 'AND po.order_id = pod.order_id '
    || 'AND pod.group_id IS NULL '
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT DISTINCT ' || v_sql_select || v_sql_from || v_sql_where || v_sql_order_by
    USING v_open_status, v_requested_status, v_cancelled_status, v_closed_status;
    ELSE
    v_sql_where := v_sql_where || ' ' || v_status_where
    || 'AND pog.group_id = :v_group_for_search '
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT ' || v_sql_select || v_sql_from || v_sql_where || v_sql_order_by
    USING v_open_status, v_requested_status, v_cancelled_status, v_closed_status, v_group_for_search;
    END IF;
    ELSIF UPPER(v_search_type_in) = 'SHIPPINGNAME'
    THEN
    v_upper_search_value1 := UPPER(v_search_value1_in);
    v_sql_where := v_sql_where || ' ' || v_group_where
    || 'AND po.upper_shipping_name LIKE ''%'' || :v_upper_search_value1 || ''%'' '
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT ' || v_sql_select || v_sql_from || v_sql_where || v_sql_order_by
    USING v_upper_search_value1;
    ELSIF UPPER(v_search_type_in) = 'USERNAME'
    THEN
    v_lower_search_value1 := LOWER(v_search_value1_in);
    v_sql_from := v_sql_from || ' ,sxweb01.customer c ';
    v_sql_where := v_sql_where || ' ' || v_group_where
    || 'AND po.customer_id = c.customer_id '
    || 'AND c.username LIKE ''%'' || :v_lower_search_value1 || ''%'' '
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT ' || v_sql_select || v_sql_from || v_sql_where || v_sql_order_by
    USING v_lower_search_value1;
    ELSIF UPPER(v_search_type_in) = 'BILLINGADDRESS1'
    THEN
    v_upper_search_value1 := UPPER(v_search_value1_in);
    v_sql_from := v_sql_from || ' ,order_payment op '
    || ' ,credit_card cc '
    || ' ,om_address oma '
    v_sql_where := v_sql_where || ' ' || v_group_where
    || 'AND po.order_id = op.business_object_id '
    || 'AND op.business_object_type = ''ORDR'' '
    || 'AND op.payment_method = ''CRCD'' '
    || 'AND op.payment_method_id = cc.credit_card_id '
    || 'AND cc.address_id = oma.address_id '
    || 'AND UPPER(oma.address1) LIKE ''%'' || :v_upper_search_value1 || ''%'' '
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT ' || v_sql_select || v_sql_from || v_sql_where || v_sql_order_by
    USING v_upper_search_value1;
    ELSIF UPPER(v_search_type_in) = 'SHIPPINGADDRESS1'
    THEN
    v_upper_search_value1 := UPPER(v_search_value1_in);
    v_sql_from := v_sql_from || ' ,shipping_info si '
    || ' ,om_address oma '
    v_sql_where := v_sql_where || ' ' || v_group_where
    || 'AND po.order_id = si.order_id '
    || 'AND si.ship_to_address_id = oma.address_id '
    || 'AND UPPER(oma.address1) LIKE ''%'' || :v_upper_search_value1 || ''%'' '
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT ' || v_sql_select || v_sql_from || v_sql_where || v_sql_order_by
    USING v_upper_search_value1;
    ELSIF UPPER(v_search_type_in) = 'BILLINGPHONE'
    THEN
    v_sql_from := v_sql_from || ' ,order_payment op '
    || ' ,credit_card cc '
    v_sql_where := v_sql_where || ' ' || v_group_where
    || 'AND po.order_id = op.business_object_id '
    || 'AND op.business_object_type = ''ORDR'' '
    || 'AND op.payment_method = ''CRCD'' '
    || 'AND op.payment_method_id = cc.credit_card_id '
    || 'AND cc.home_phone = :v_search_value1_in '
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT ' || v_sql_select || v_sql_from || v_sql_where || v_sql_order_by
    USING v_search_value1_in;
    ELSIF UPPER(v_search_type_in) = 'SHIPPINGPHONE'
    THEN
    v_sql_from := v_sql_from || ' ,shipping_info si '
    v_sql_where := v_sql_where || ' ' || v_group_where
    || 'AND po.order_id = si.order_id '
    || 'AND si.ship_phone = :v_search_value1_in '
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT ' || v_sql_select || v_sql_from || v_sql_where || v_sql_order_by
    USING v_search_value1_in;
    ELSIF UPPER(v_search_type_in) = 'CREDITCARDNUMBER'
    THEN
    v_sql_from := v_sql_from || ' ,order_payment op '
    || ' ,credit_card cc '
    v_sql_where := v_sql_where || ' ' || v_group_where
    || 'AND po.order_id = op.business_object_id '
    || 'AND op.business_object_type = ''ORDR'' '
    || 'AND op.payment_method = ''CRCD'' '
    || 'AND op.payment_method_id = cc.credit_card_id '
    || 'AND cc.credit_card_number = :v_search_value1_in '
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT ' || v_sql_select || v_sql_from || v_sql_where || v_sql_order_by
    USING v_search_value1_in;
    ELSIF UPPER(v_search_type_in) = 'PONUMBER'
    THEN
    v_sql_from := ' '
    || 'FROM ' || ' product_order_detail_actv_v pod ,' || SUBSTR(v_sql_from, 6);
    v_sql_where := v_sql_where || v_group_where
    || 'AND pod.po_no = :v_search_value1_in '
    || 'AND po.order_id = pod.order_id '
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT /*+ ORDERED */ DISTINCT ' || v_sql_select || v_sql_from || v_sql_where
    USING v_search_value1_in;
    ELSIF UPPER(v_search_type_in) = 'USERASSIGNED'
    THEN
    IF v_search_value1_in = '0' -- 'Unassigned'
    THEN
    v_sql_where := v_sql_where || ' ' || v_group_where || ' ' || v_status_where
    || 'AND pog.unassigned_flag = ''Y'' '
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT ' || v_sql_select || v_sql_from || v_sql_where || v_sql_order_by
    USING v_open_status, v_requested_status, v_cancelled_status, v_closed_status;
    ELSE
    v_sql_where := v_sql_where || ' ' || v_group_where || ' ' || v_status_where
    || 'AND pog.dn_employee_id = :v_search_value1_in '
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT ' || v_sql_select || v_sql_from || v_sql_where || v_sql_order_by
    USING v_open_status, v_requested_status, v_cancelled_status, v_closed_status, v_search_value1_in;
    END IF;
    ELSIF UPPER(v_search_type_in) = 'ORDERDATE'
    THEN
    v_sql_where := v_sql_where || ' ' || v_group_where || ' ' || v_status_where
    || 'AND po.order_date BETWEEN TO_DATE( :v_search_value1_in, ''MON DD YYYY HH24:MI:SS'') AND TO_DATE( :v_search_value2_in ,''MON DD YYYY HH24:MI:SS'') '
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT ' || v_sql_select || v_sql_from || v_sql_where || v_sql_order_by
    USING v_open_status, v_requested_status, v_cancelled_status, v_closed_status, v_search_value1_in, v_search_value2_in;
    ELSIF UPPER(v_search_type_in) = 'PRINTJOB'
    THEN
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT ' || v_sql_select
    || ' '
    || 'FROM product_order po '
    || ' ,bcf_print_jobs pj '
    || 'WHERE 1 = 1 '
    || 'AND pj.order_id = po.order_id '
    || 'AND pj.username = :v_search_value1_in '
    || 'AND pj.create_date = TO_DATE( :v_search_value2_in,''MON DD YYYY HH24:MI:SS'') '
    || v_sql_order_by
    USING v_search_value1_in, v_search_value2_in;
    ELSIF UPPER(v_search_type_in) = 'FULFILLMENTTYPE'
    THEN
    v_sql_from := v_sql_from || ' ,product_order_detail_actv_v pod ';
    v_sql_where := v_sql_where || ' ' || v_group_where || ' ' || v_status_where
    || 'AND pod.order_id = po.order_id '
    -- Because we have to drill down the the POD level
    -- we now need to ensure the pod records match on group
    || 'AND pod.group_id = ' || v_group_for_search
    -- We curr. have 3 fufillment types FC165, FC212, FCBABY
    -- so substr on 1st char works for Garry
    || 'AND UPPER(SUBSTR(pod.fulfillment_type,1,1)) = UPPER(:v_search_value1_in) '
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT DISTINCT ' || v_sql_select || v_sql_from || v_sql_where || v_sql_order_by
    USING v_open_status, v_requested_status, v_cancelled_status, v_closed_status, v_search_value1_in;
    ELSIF UPPER(v_search_type_in) = 'INSUFFICIENTAUTHORIZATION'
    THEN
    v_sql_where := v_sql_where
    || 'AND bcf_get_authorization_amount(po.order_id) > 0'
    IF (outcursor%ISOPEN) THEN
    CLOSE outcursor;
    END IF;
    OPEN outcursor FOR
    'SELECT ' || v_sql_select || v_sql_from || v_sql_where || v_sql_order_by;
    END IF;
    END order_search;
    --

  • Problem in JDBC , when using LIKE operator. - VERY URGENT

    Problem in JDBC , when using LIKE operator.
    LINE 1 : String temp = "AA";
    LINE 2 : String query = "select * from emp where EMPNAME like '*temp*' ";
    LINE 3 : Staement st = con.createStaement();
    LINE 4 : ResultSet rs = st.executeQuery(query);
    '*' character is not getting evaluated. In MS ACCESS2000 only * is accepted instead of '%'. Moreover in MS ACCESS the like operator has to be used within double quotes as a String. whereas in other databases, it accepts single quotes as a String.
    Ex:
    In MS ACCESS
         select * from emp where ename like "*aa*";
    Other Databases
         select * from emp where ename like '%aa%';
    In my situation iam passing a Variable inside a like operator and '*' is used.
    For the above Scenario, Please help me out.
    If possible Kindly let me know the exact Syntax.
    Please give me the answer as LINE1,LINE2,LINE3,LINE4,
    I have verified in JDBC Spec also, it has been specified to use escape sequence.that too did not work.
    Due to this, My project is in hold for about 4 days. I could not find a suitable solution.
    Please help me out.

    I made a LIKE clause work with M$ Access, using PreparedStatement and the % wildcard:
                escapeStr                   = "%";
                String sql                  = "SELECT USERNAME, PASSWORD FROM USERS WHERE USERNAME LIKE ?";
                PreparedStatement statement = connection.prepareStatement(sql);
                statement.setString(1, ("user" + escapeStr));
                ResultSet resultSet         = statement.executeQuery();
                while (resultSet.next())
                    System.out.println("username: " + resultSet.getObject("USERNAME") + " password: " + resultSet.getObject("PASSWORD"));

  • 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

  • How to write statement using LIKE statement in jsp

    hi
    I am new to jsp. I would like to retrive the data from database using like command. But my query dosen't work well. Can you help me in this topic.
    String name = request.getParameter("username");
    int i = st.executeQuery("select * from emp where empname LIKE '%name%'");
    Plase help me..
    Thanking you
    sure...

    Using LIKE :
    ==========
    The following SQL statement will return persons with first names that start with an 'O':
    SELECT * FROM Persons
    WHERE FirstName LIKE 'O%'
    The following SQL statement will return persons with first names that contain the pattern 'la':
    SELECT * FROM Persons
    WHERE FirstName LIKE '%la%'
    Hope this might have helped you
    REGARDS,
    RaHuL

  • How to use LIKE operator with PreparedStatement

    Hi, I need to execute a query with the LIKE operator, but using a PreparedStatement. Can I do this, and if so what must my SQL look like with the wildcard characters '%' or '_'?
    normal PS example: conn.prepareStatement("select * from mytable where name like ?");
    If I try: conn.prepareStatement("select * from mytable where name like ?%");
    I get: ORA-00911: invalid character
    If I try: conn.prepareStatement("select * from mytable where name like '?%'");
    I get: ORA-01006: bind variable does not exist
    I must use a PreparedStatement, as my variable may contain illegal characters (like '), and using PreparedStatement.setString(1, var) will automatically escape it for me.
    I could also use a normal Statement, but I need to escape my var ... is there a utility that will safely escape a String for an Oracle VARCHAR2??
    Thanks in advance,
    Stu Miller

    Hmm, it seems you are right...
    when my variable contains a '%' symbol, the PreparedStatement will NOT escape it, and thus it is treated like a wildcard. Therefore, I can just do
    pstmt.setString(1, var+"%");
    But, that may return more results than I'm asking for, as when 'var' contains a '%' symbol it is taken as a wildcard too.
    I need each character in my variable to be taken literally, and only add a wildcard at the end. Basically, I need a STARTSWITH operator ;-)
    It seems to me that escaping the sensitive characters in a String (which will differ depending on which operator is used), should be possible. I could write this, but I was hoping Oracle had already done it for me in some utility class.

  • 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

  • Generate a SQL "IN" clause using ALDSP

    Problem Summary
    ALDSP: Generate a SQL "IN" clause
    Problem Description
    I would like to know if there is a possibility of generating an SQL "IN" clause using ALDSP.
    I would need the XQuery construct to create an SQLsomething like-
    select * from emp where dept_no in ('101', '201', '301');
    The values for dept_no would be passed at runtime.
    (Or)
    Will be I able to create a physical data service using the SQL - select * from emp where dept_no in ?
    If yes, how do I map the parameter to "?"
    Thanks.

    Mike,
    Thanks for the response. The section that you are taking about is to push joins to DB. Joining tables is not the problem that I am facing.
    I will rephrase the problem.
    I would like to know if there is a possibility of creating a ALDSP physical data service (.ds file) with the SQL as select * from employee where emp_id in ?
    and I should be able to pass multiple employee ids to the "?" parameter. select * from emp where emp_id in ('101', '201', '301');
    There is no fixed number of ids that a user can pass.
    Thanks.

  • 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

Maybe you are looking for

  • Error While Adding a Software Component

    Hi All, While adding a software component in the SLD, i am getting the below error. Can anybody please suggest me the possible reason for the same. Storing changes to persistence failed. Please check both your J2EE engine and database are in a health

  • Manual change of condition types in a pricing procedure

    Hi, I want to know the difference between a) Setting value as C (Manual entry has priority) in the Manual Entry field of the condition type (transaction V/06) and b) Setting the checkbox of "Condition determined manually" checked in the pricing proce

  • How 2 Edit the DEFAULT&SMARTBAR ?

    Hello Pls i want 2 know : How 2 Edit the DEFAULT&SMARTBAR ?! To read Arabic Characters Besides How 2 change it's direction from left to the right ? Regards Abdetu...

  • Set User-status for PP order

    Hi All, How can I set the user-status for a PP order, also let me know which user exit suits this requirement, as I know I have to make use of a FM or a BAPI which sets the user-status in the user-exit somewhere. Thanks Mark

  • End of life status for JDK 1.1.8

    I am currently using JDK 1.1.8-003, but I notice from the Sun website that they have begun the end of life process for this product and they will not be supporting it beyond October 09 2002. I should be grateful for advice on which newer version of S