[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

07/31/2009 at 10:56AM PDT, ID: 24617477
[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!

6.8

How to write ref cursor query in Oracle Reports

Asked by vishal_singh in Oracle 9.x, Oracle 10.x, PL / SQL

Tags: Oracle Reports 9i

Hello Guys!!

I have a form in which you can select regions/divisions/locations etc by the use of check boxes. And the selected values will be inserted into a table, and based on the selected values of the table the report is run.
The issue I have is with the query inside the Oracle reports(attached to this file).
The query works fine until the last two EXISTS conditions.
IF a region exists In the table report_param then it works fine but if there are no divisions in it , then the query returns no values, which is not correct.

Someone has advised me to use a ref-cursor query inside reports tool, which I am not aware off. So, anykind of suggestions or advises are welcome. Please let me know about it as it is very urgent issue for me. Anykind of help would be greatly
appreciated.

Thanks,
 Vishal
 
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:
53:
54:
55:
56:
57:
58:
59:
select c.key_segment, p.supplier_id, 
             decode(:in_col_nm, 'BRAND',nvl(p.product_brand,'<Unknown Brand>'), 'PLN',nvl(p.product_legal_name,'<Unknown Legal Name>')) COL_NM,
             sum(a.ext_price) sales_dols,
             sum(comp_allow_pkg.get_comp_allow_stddiv(a.control_loc_id, a.product_id, a.sold_to_customer_id,
                                                                                       a.doc_dt, a.ext_price, a.units)) cust_reb_dols, 
             sum(a.units) units, 
             sum(a.ext_cost) cost_dols
      from sales a, key_segment_plns c, product p, rep_wrtr_dw_cust h
      where a.doc_dt between :in_start_dt and :in_end_dt
      and   a.customer_oc = h.control_loc_id
      and   a.sold_to_customer_id = h.sold_to_cust_id
      and   a.ship_to_customer_id = h.ship_to_cust_id
      and   ((:in_dg_cd = 'B' and h.dealer_grower_cd in ('D','G')) or h.dealer_grower_cd = :in_dg_cd)
      and   a.product_id = p.product_id
      and   p.product_gl_class_cd = 'CHEM'
      and   p.product_legal_name = c.product_legal_name
      and   c.key_segment in ('GLYPHOSATE','PLANT HEALTH/RUST FUNGICIDES','PYRETHROIDS','STROBI FUNGICIDES')--&IN_KEY_SEGMENTS
     -- and    (:in_oc = 'ALL' or (a.control_loc_id in (select control_loc from control_loc_comb_ocs where control_loc_comb = :in_oc)))
      -- SALES DATA FILTERS TO MATCH ACCUM_SALES_DG_MV
      and   a.sale_type_cd in ('02','08')
      and   a.document_type_cd in ('I','C','D')
      and   (substr(a.product_id,-1) in ('0','1') OR nvl(upper(trim(p.product_brand)),'X') = 'TECH FEE')
      and   a.units <> 0
      and   a.unit_cost <> 0
      and   a.unit_price <> 0    
      -- NEW FILTERS  ADDED 9/11/07: LOCATION(BRANCH), BUSINESS TYPE, RSM/ASM/REP
      and   ((:in_loc = 'ALL') or (nvl(a.warehouse_id,'<blank>') in (SELECT param_value
                                                                        FROM   report_param
                                                                        WHERE  report_id = :IN_REPORT_ID
                                                                        AND    session_id= :IN_SESSION_ID
                                                                        AND    USER_ID   = :IN_USER_ID
                                                                        AND    param_name='LOCATION_TYPE')))
      and   ((:in_uhs_ag = 'ALL') or (:in_uhs_ag = 'NA' and p.product_uhs_ag != 'A') or (p.product_uhs_ag = :in_uhs_ag))
      and   ((:in_sales_rep = 'ALL') or  (nvl(a.territory_id,'<blank>') in (SELECT param_value
                                                                        FROM   report_param
                                                                        WHERE  report_id = :IN_REPORT_ID
                                                                        AND    session_id= :IN_SESSION_ID
                                                                        AND    USER_ID   = :IN_USER_ID
                                                                        AND    param_name='SALES_REP_TYPE')))
      and    EXISTS
            (SELECT '1'
             FROM  locations l, report_param rp
             WHERE rp.report_id = :IN_REPORT_ID
             AND   rp.session_id= :IN_SESSION_ID
             AND   rp.user_id   = :IN_USER_ID
             AND   rp.param_value = l.region
             AND   rp.param_name = 'REGION_TYPE'
             AND   a.warehouse_id = L.ARS_LOCATION) 
      and    EXISTS
            (SELECT '1'
             FROM  locations l, report_param rp
             WHERE rp.report_id = :IN_REPORT_ID
             AND   rp.session_id= :IN_SESSION_ID
             AND   rp.user_id   = :IN_USER_ID
             AND   rp.param_value = l.region
             AND   rp.param_name = 'DIVISION_TYPE'
            AND   a.warehouse_id = L.ARS_LOCATION)        
      group by c.key_segment, P.supplier_id, 
      decode(:in_col_nm, 'BRAND',nvl(p.product_brand,'<Unknown Brand>'), 'PLN',nvl(p.product_legal_name,'<Unknown Legal Name>'))
[+][-]07/31/09 02:06 PM, ID: 24992459

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/31/09 02:19 PM, ID: 24992542

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/03/09 12:54 PM, ID: 25008047

View this solution now by starting your 30-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: Oracle 9.x, Oracle 10.x, PL / SQL
Tags: Oracle Reports 9i
Sign Up Now!
Solution Provided By: Andytw
Participating Experts: 2
Solution Grade: B
 
 
[+][-]08/30/09 02:05 PM, ID: 25219353

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

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

 
 
Loading Advertisement...
20091111-EE-VQP-91 - Hierarchy / EE_QW_3_20080625