How to pass variable into lov sql query using like operator
hi.
i want to use a lov where i want to pass a variable using like operator.
my query is
select empno,name from table where empno like ':ed%';
my empno is A001 TO A199 AND B001 TO B199 so i want show either A% or B% empno
how can i do this ?
reagrds
kindly press Shift+F1 at a time you face this error to see the exact Oracle error message.
and provide us with that detail
and its better if you start new topic for that error... because that will be new error,,,
-- Aamir Arif
Edited by: Aamiz on Apr 7, 2010 12:27 PM
Similar Messages
-
How to pass variables into an alert
Hi,
I have set up an alert control step in my BPM, and completed all the required config to see the alert is created in my alert inbox. However, I want to pass some parameters into the alert message, such as po number. Does anyone know how to do it? I already defined the variables in the alert category container.
Your help is appreciated!
HartHi Hart
I don't know if my way is "recommended" but...:)
1. don't define container variable in alert def
2. select "dynamic text" in your alert category
(if you select this you'll be able to pass text from "alert message" to the alert)
now it should work
passing variables into the long text
of the alert message works for me just great
Hope it will for you to:)
Kind Regards,
Michal Krawczyk
https://www.sdn.sap.com/sdn/weblogs.sdn?blog=/pub/u/34500 [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] -
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 PMPROCEDURE 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;
-- -
How to pass a result of SQL query to shell script variable
Hi all,
I am trying to pass the result of a simple SQL query that only returns a single row into the shell script variable ( This particular SQL is being executed from inside the same shell script).
I want to use this value of the variable again in the same shell scirpt by opening another SQL plus session.
I just want to have some values before hand so that I dont have to do multiple joins in the actual SQL to process data.Here an example :
SQL> select empno,ename,deptno from emp;
EMPNO ENAME DEPTNO
7369 SMITH 20
7499 ALLEN 30
7521 WARD 30
7566 JONES 20
7654 MARTIN 30
7698 BLAKE 30
7782 CLARK 10
7788 SCOTT 20
7839 KING 10
7844 TURNER 30
7876 ADAMS 20
7900 JAMES 30
7902 FORD 20
7934 MILLER 10
14 rows selected.
SQL> select * from dept;
DEPTNO DNAME LOC
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
$ cat my_shell.sh
### First query #####
ENAME_DEPTNO=`sqlplus -s scott/tiger << EOF
set pages 0
select ename,deptno from emp where empno=$1;
exit
EOF`
ENAME=`echo $ENAME_DEPTNO | awk '{print $1}'`
DEPTNO=`echo $ENAME_DEPTNO | awk '{print $2}'`
echo "Ename = "$ENAME
echo "Dept = "$DEPTNO
### Second query #####
DNAME_LOC=`sqlplus -s scott/tiger << EOF
set pages 0
select dname,loc from dept where deptno=$DEPTNO;
exit
EOF`
DNAME=`echo $DNAME_LOC | awk '{print $1}'`
LOC=`echo $DNAME_LOC | awk '{print $2}'`
echo "Dept Name = "$DNAME
echo "Dept Location = "$LOC
$ ./my_shell.sh 7902
Ename = FORD
Dept = 20
Dept Name = RESEARCH
Dept Location = DALLAS
$ -
How to pass two parameters to sql query
I try to create a sql script to update two columns in one table. I want to set it as parameter. When people execute this sql script, they need to pass parameter into sql query, then query will be executed successfully. The problem is I am only able to pass one parameter. If set two parameters in one line code, it will get ORA-00933 errors. Please advice me where I was wrong. The code is simple and like this:
update MY_TABLE set year = &year AND month = &month where application_type = 'xxxx';
If I only have: update MY_TABLE set year = &year where application_type = 'xxxx'; It works. If I set two parameters to pass value. It will get error.Hi,
When you UPDATE two or more columns in the same statement, use ',' instead of 'AND' to separate them:
update MY_TABLE
set year = &year
, month = &month
where application_type = 'xxxx';The correct syntax for all SQL statements, including UPDATE, can be found in the [SQL Language manual|http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_10008.htm#sthref9598]. -
Pass Variables into AS3 through Query String?
Man! I've been searching ferociously and can't seem to find a solution that works for me. I am trying to pass variables via query string on a PHP page to Flash, and then have the swf add movie clips to the stage depending on the information it receives.
Here is what the PHP outputs:
swfobject.embedSWF("flash/detailScore.swf?a=0-0&b=0-0&c=30-54&d=30-20&e=42-18", ...
And here is my AS3 code:
function loaderInfoSh(e:Event):void{
var myQueryStrings=this.loaderInfo.parameters;
a = myQueryStrings.a;
b = myQueryStrings.b;
c = myQueryStrings.c;
d = myQueryStrings.d;
e = myQueryStrings.e;
addTheResults(a,1);
addTheResults(b,2);
addTheResults(c,3);
addTheResults(d,4);
addTheResults(e,5);
this.loaderInfo.addEventListener(Event.COMPLETE, loaderInfoSh);
The addTheResults function takes the coordinates, adds a MC instance to the stage and positions it accordingly.
var colorMCArray:Array = new Array();
function addTheResults(val,colnum:Number){
if(val == null){val = "52-46";} // so I can test it locally
var daColor:String;
switch (colnum){
case 1:
daColor = "f3951c";
break;
case 2:
daColor = "74b47d";
break;
case 3:
daColor = "436494";
break;
case 4:
daColor = "9b74ac";
break;
case 5:
daColor = "b43d44";
break;
var dash:int = val.indexOf("-");
var lateral = val.slice(0,dash);
var vertical = val.slice(dash+1);
lateral --;
vertical --;
// adding the MC instance
var comm:tileB = new tileB();
comm.name = "comm"+colnum;
addChild(comm);
colorMCArray[colnum] = comm;
//Change the color
var colorTransform:ColorTransform = colorMCArray[colnum].transform.colorTransform;
var thiscolor = "0x"+daColor;
colorTransform.color = thiscolor;
colorMCArray[colnum].transform.colorTransform = colorTransform;
colorMCArray[colnum].x = 5;
colorMCArray[colnum].y = 536;
colorMCArray[colnum].x += (lateral * 9);
colorMCArray[colnum].y += (vertical * 9)*-1;
colorMCArray[colnum].addEventListener(MouseEvent.MOUSE_OVER, btnro);
colorMCArray[colnum].addEventListener(MouseEvent.MOUSE_OUT, btnrout);
I don't know what I'm doing wrong here.Was this the "e" in the code below you were pertaining to as the culprit? "e" is not a keyword. It's just the shortcut for the word "event" for the variable name of type Event which is the Event object that triggered the call of function loaderInfoSh. In your code you assigned e = myQueryString.e which should have given you a type mismatch error.
function loaderInfoSh(e:Event):void{
var myQueryStrings=this.loaderInfo.parameters;
a = myQueryStrings.a;
b = myQueryStrings.b;
c = myQueryStrings.c;
d = myQueryStrings.d;
e = myQueryStrings.e;
addTheResults(a,1);
addTheResults(b,2);
addTheResults(c,3);
addTheResults(d,4);
addTheResults(e,5);
this.loaderInfo.addEventListener(Event.COMPLETE, loaderInfoSh); -
I want to do an SQL query which uses a parameter. This is the query: Find the books which contains the string "strTitle". I do this (it does not work):
String strSQL="SELECT * FROM Books WHERE Title LIKE %'"+strTitle+"'% ";
I know it is not correct, but anyone any idea of how i can do it?
ThanksHi,
You can also use a PreparedStatement, for not-worrying about quotes:
PreparedStatetment ps=con.prepareStatement(theQuery);
ps.setString(1, likeString);
ResultSet r=theQuery.execute();
// etc...
where :
String theQuery=new String("SELECT * FROM PERSON WHERE NAME LIKE ?;");
likeString='\%'+theStringSearching+'\%';
also, likeString could be a custom method for making more complicated searches by one Like Statement,
that needs reeding about RegExpressions.
cheers, Thanasis -
SQL Query With Like Operator - Performance is very poor - Oracle Apps Table
Hi,
I'm querying one of the Oracle Applications Standard Table. The performance is very slow when like operator is used in the query condition. The query uses a indexed column in the where clause.
The query is..
select * from hz_parties
where upper(party_name) like '%TOY%'
In the above case, It is not using the index and doing full table scan. I have checked the explain plan and the cost is 4496.
select * from hz_parties
where upper(party_name) like 'TOY%'
If I remove the '%' at the begining of the string, the performance is good and it is using the index. In this case, the cost is 5.
Any ideas to improve the performance of the above query. I have to retrieve the records whose name contains the string. I have tried hints to force the use of index. But it is of no use.
Thanks,
RamaIf new indexes are disallowed, not a lot of good ones, no.
If you know what keyword(s) are going to be searched for, a materialized view might help, but I assume that you're searching based on user input. In that case, you'd have to essentially build your own Text index using materialized views, which will almost certainly be less efficient and require more maintenance than the built-in functionality.
There may not be much you could do to affect the query plan in a reasonable way. Depending on the size of the table, how much RAM you're willing to throw at the problem, how your system is administered, and what Oracle Apps requires/ prohibits in terms of database configuration, you might be able to force Oracle to cache this table so that your full table scans are at least more efficient.
Justin -
Need sql query for like operation.
Hi All,
i have table like name column and contain the data like
ibm 100
ibm 200
ibm 300
a2b
a
b
c
like this ....
but sql query need search using like or any regular expression---
select * from table where name like (ibm 200 and ibm 300).
and i don't want use like this select * from table where name like' ibm 200' or name like 'ibm 300').
can you please any body help to correct the above query...
Edited by: anbarasan on Oct 16, 2011 10:02 PMWITH t AS
(SELECT 'ibm 100' NAME
FROM DUAL
UNION ALL
SELECT 'ibm 200' NAME
FROM DUAL
UNION ALL
SELECT 'ibm 300' NAME
FROM DUAL
UNION ALL
SELECT 'a2b' NAME
FROM DUAL)
SELECT *from t where REGEXP_LIKE (name, 'ibm')
and REGEXP_LIKE (name, '100|200') -
Pass variable into execute sql task
hi
i want to execute my stored proc, in ssis package . i have 2 parameter, so i need pass values from another table one by one.
i need to execute stored proc for each from another table, by passing values
how to do ithi
i want to execute my stored proc, in ssis package . i have 2 parameter, so i need pass values from another table one by one.
i need to execute stored proc for each from another table, by passing values
how to do it
You can do it as follows
1. Add a variable of type object in SSIS
2. Add a execute sql task with query as
SELECT field1,field2
FROM Table
Set resultset option as Full resultset and in resultset tab map the resultset to object variable.
3. Add a ForEach loop with ADO enumerator and map it to object variable. Inside loop add two variable to get each iterative values for field1 and field2
4. Inside loop add a execute sql task and set command as
EXEC ProcedureName ?,?
Map the parameters to two variables created inside the loop.
On executing package the procedure gets executed for each record in the table.
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
How to pass variable to jump to query !
hello Experts !
i have a query with variable "Month". so when i run that , user enters the Month/year and it gives the results for "Employee ID" for that month/year.
i have also creted another query on dso, in order to get detail line item information abt " Employee ID" and join this query with the main one thru RRI.
in RRI , i have selected "Employee ID" as single value field for both the query. the problem is when i do GOTO from the first query , it does work and gives me the result, but it gives records corresponds to that "Employee id"for all the months and year.
How do i also pass "Month" - variable value along with that "Employee id" so that the second query only shows line item for that employee id for that selected month.
thanxHi,
The use of jump query is to get the detailed level information, for the key figure values which appears in main query.
This mainly happen when in your cube design you do not details information.
For example:
In your main query output you have :
division , company code , variable amount
Rec1)10, 1012,4000
Rec2)20,1001,5000
Now you want to know what are the document numbers involved to get the variable amount:
So now , you jump query output will be for record no 1.
Document number , variable amount
100001,500
100002,1000
100003,2000
100004,500
So now you can see that jump query is giving you the documents numbers which are total of 4000.
Once you have variable in main query , the jump will give details of those keyfigur values only.
In case of jump query you need not to have any variable , it will automatically take from parant query.
Though you can define varaible for jump also.
I hope it clear your doubt
Thanks
Mayank -
Passing Variables to a SQL Query
I have a select box with multiple choices allowed in
form1.ASP. I want =
to pass the form on submit using request.form ("variable")
and process =
data and a query string for an SQL select where statement.
The form =
data is in the format of "E123 B456 X789" . What is the best
means of =
processing that for my Access database?
Thanks.
RossWell, here's the answer:
http://kb.adobe.com/selfservice/viewContent.do?externalId=3Dtn_15906&slic=
eId=3D1
"ross m. greenberg" <[email protected]> wrote in
message =
news:gb5reg$714$[email protected]..
I have a select box with multiple choices allowed in
form1.ASP. I want =
to pass the form on submit using request.form ("variable")
and process =
data and a query string for an SQL select where statement.
The form =
data is in the format of "E123 B456 X789" . What is the best
means of =
processing that for my Access database?
Thanks.
Ross -
How to pass parameters to a SQL query or Data template
Hi,
The requirement is that my final report will take 'date' as input from the user and print only those records which have date later than the user-supplied 'date'. ('Date' is a field in the database).
I know the way to achieve this is to use user-defined parameters.
I have read the user guide, and have created user parameters. From the user guide: "The Report Editor allows you to define your query, define
the parameters that you want users to pass to the query,..."
However there is no example given. (I could not find).
Any guidance?Are you using Enterprise Server environment ? If so, you can find a sample report in the Shared Folders under HR Manager - Employee Salary Report. Please revert if you still have confusion.
-
How to pass variables into flex movies form the url
I used to do this in Flash 8 using swfobject, but it does not
seem to work with Flex.
Anyone can provide an example on how to do this.
Thanks,
GilbertZClaes,
Thanks. But where do i put the following code on the html
page (from the example of your link):
<%
String fName = (String) request.getParameter("firstname");
String mName = (String) request.getParameter("middlename");
String lName = (String) request.getParameter("lastname");
%>
Gilbert -
How to achive equivalent of contains in java using Like operator
Hi,
Could anyone please enlighten me on this issue.
I need to achieve through the query to reduce the unnecessary of loop through.
Lets say:
I have a table called BLACKLISTPASSWORD with column BPW.
example record in column (BPW)
Welcome
Welcome1
Welcome123
I want make a query like
SELECT BPW
FROM BLACKLISTPASSWORD
WHERE lower(BPW) LIKE 'welcome1234%'Expecting a result true if any sequence matches in above case expecting true bcz Welcome123 is there in DB.
Plz correct me in the query to achieve this.
Edited by: Deekay on Aug 2, 2012 12:40 AMDeekay wrote:
Hi,
Could anyone please enlighten me on this issue.
I need to achieve through the query to reduce the unnecessary of loop through.
Lets say:
I have a table called BLACKLISTPASSWORD with column BPW.
example record in column (BPW)
Welcome
Welcome1
Welcome123
I want make a query like
SELECT BPW
FROM BLACKLISTPASSWORD
WHERE lower(BPW) LIKE 'welcome1234%'Expecting a result true if any sequence matches in above case expecting true bcz Welcome123 is there in DB.
Plz correct me in the query to achieve this.
Edited by: Deekay on Aug 2, 2012 12:40 AMYou can use as
SELECT BPW
FROM BLACKLISTPASSWORD
WHERE lower(BPW) LIKE 'welcome%'This will return
Welcome
Welcome1
Welcome123
If you want Output as
>
Welcome1
Welcome123
>
i.e. Welcome followed by a/more digits; Below works on Oracle 10g or higher.
SELECT BPW
FROM BLACKLISTPASSWORD
WHERE regexp_like(BPW, 'welcome[[:digit]]+', 'i');
Maybe you are looking for
-
Apple Iphone 5 transfer to and from computer on a Windows 8.1 64 bit machine? Do I need to download a driver so that the computer will recognize the device?
-
Link between slides & sound files broken
Following an inadvertant folder move the slides in a slideshow are not now linked to the corresponding narrative sound files. Can the link be re-eastablished and if so how? Peter Goldsworthy
-
UserAccountUpdater message at startup
I recently installed Mountain Lion on my MacBook Pro and have since had "UserAccountUpdater is trying to modify the system network configuration. Type your password to allow this." appear at startup before I even have a chance to sign in to my accoun
-
Modifying aspect ratio of iTunes TV shows
I recently downloaded the 2008 Stanley Cup Final on iTunes TV. The video is vertically distorted; that is to say, it plays back at a 4:3 aspect ratio when the video is clearly taken from the 16:9 HD broadcast. How do I set iTunes to play the video ba
-
FRM-40735 when validate-item_trigger raised unhandled exception ORA 06502
Hi, after i migrated my form to 10g when I enter a new record into the form and want to save I get the following message: Frm-40735 when validate-item_trigger raised unhandled exception ORA 06502 what could be the reason? It worked before in 6i but n