Advertisement

03.25.2008 at 07:07AM PDT, ID: 23266994
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.2

Oracle Dynamic Search Query

Asked by Jeffreymarcum in PL / SQL, Oracle Database, Oracle 10.x

Tags:

I'm building an SQL search query in Oracle that passes in 4 parameters to search on. If a search paramenter is not passed in then the query defaults that parameter to null. However, there is one parameter that, if passed in null, then it needs to default to a specific criteria (see below) I need help with limiting this query parameter to 'F' and  'B' if either 'F' or 'B' is not passed in. I've included the line that is not working (commented out) and the entire code snippet.


AND (hdr.ownership_type=p_ownership OR p_ownership IN ('F','B'))Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
PROCEDURE sp_getpromotions(p_fee_sched_head_id flat_fee_sched_dev.fee_sched_head_id%TYPE DEFAULT NULL,
                           p_fee_sched_name fee_sched_hdr.fee_sched_name%TYPE DEFAULT NULL,
                           p_ownership fee_sched_hdr.ownership_type%TYPE DEFAULT NULL,
                           p_promotionstatus promotion_status.promotion_code%TYPE DEFAULT NULL,
                           p_promocur OUT sys_refcursor, 
                           p_ret OUT NUMBER,
                           p_error_txt OUT VARCHAR2) IS
                                            
        l_param_len      NUMBER       := pkg_common.sf_declared_length(p_error_txt);
        
BEGIN
    
    g_procname := 'SP_GETPROMOTION';
        
    --error return variables
    p_ret := 0;
    p_error_txt := NULL;
        
OPEN p_promocur FOR        
SELECT  hdr.fee_sched_head_id, 
        hdr.ownership_type, 
        dmd_id, ims_id, 
        hdr.fee_sched_name, 
        ps.promotion_code
FROM ssp_fee_sched_hdr hdr,
     ssp_promotion_status ps,
     
    (SELECT fsasd.fee_sched_head_id, 
            fsasd.adjud_sys_id as dmd_id, 
            fsasi.adjud_sys_id as ims_id
     FROM ssp_fee_sched_adjd_sys fsasd
          LEFT OUTER JOIN
          ssp_fee_sched_adjd_sys fsasi
          ON fsasd.fee_sched_head_id=fsasi.fee_sched_head_id
          AND fsasi.adjud_sys='IMT'
     WHERE fsasd.adjud_sys='DMD') ids
        
WHERE hdr.fee_sched_head_id=ps.fee_sched_head_id
  AND hdr.fee_sched_head_id=ids.fee_sched_head_id
  AND (hdr.fee_sched_head_id=p_fee_sched_head_id OR p_fee_sched_head_id IS NULL)
  AND (ps.promotion_code=p_promotionstatus OR p_promotionstatus IS NULL)
  --AND (hdr.ownership_type=p_ownership OR p_ownership IN ('F','B')) -- Limit by ownership type here to just 'F' or 'B' 
  AND (UPPER(hdr.fee_sched_name) LIKE '%' || UPPER(p_fee_sched_name) || '%' OR p_fee_sched_name IS NULL);                       
 
EXCEPTION
    WHEN NO_DATA_FOUND THEN
         NULL;
    WHEN OTHERS THEN
        sp_log(SUBSTR(g_package || '.' || g_procname || ' ERROR - ' || SQLERRM, 1, l_param_len));
        p_ret := -1;
        p_error_txt := SUBSTR(g_package || '.' || g_procname || ' ERROR - ' || SQLERRM, 1, l_param_len);  
END sp_getpromotions;
[+][-]03.25.2008 at 07:42AM PDT, ID: 21202354

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.25.2008 at 07:46AM PDT, ID: 21202401

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.25.2008 at 08:03AM PDT, ID: 21202564

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: PL / SQL, Oracle Database, Oracle 10.x
Tags: SQL (Oracle)
Sign Up Now!
Solution Provided By: joebednarz
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628