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

Question
[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!

8.0

Multiple Case statements in Select generates an error when compiled into a pkg/stored procedure

Asked by tf842 in Oracle Product Info

Tags: case, compilation, created, procedure

oracle 8.1.7 database using oracle 9.2.0.4 client. (eventually I will use this in vb.net with odp.net 9.2.0.4.1, very similar error by the way.)

The select statement works very good in sqlplus just the way it is. (The schema's have been changed to protect the innocent.)

One site I found said you can wrap the sql in an execute immediate, but I do not know how to do this within a package, nor with the code below.

The following error is generated when compiling the pkg:
( I inserted the ==>8)

*******
PACKAGE BODY testprod.QUOTE1_DBPKG
On line:  8
PLS-00103: Encountered the symbol "CASE" when expecting one of the following:

   ( - + mod null <an identifier>
   <a double-quoted delimited-identifier> <a bind variable>
   table avg count current
********
my Package code:
CREATE OR REPLACE PACKAGE testprod.QUOTE1_DBPKG AS
  TYPE QuoteCur IS REF CURSOR;
  PROCEDURE GetForSelect (QuoteOutCur OUT QuoteCur);

END QUOTE1_DBPKG;
Package created
 
CREATE OR REPLACE PACKAGE BODY testprod.QUOTE1_DBPKG AS
  PROCEDURE GetForSelect (QuoteOutCur OUT QuoteCur)
  IS
  LocalQuoteCur QuoteCur;
  BEGIN
         OPEN LocalQuoteCur FOR
   SELECT q.quote_key as Quote_Key, q.is_nc_merchant,
==>8         CASE
             WHEN q.is_nc_merchant = 1 THEN (select customer_name
                     from testprod.non_customer nc
                    where q.MERCHANT_CUST_KEY = nc.CUSTOMER_KEY)
             ELSE (select customer_name
                     from prod.customer c
                    where q.MERCHANT_CUST_KEY = c.CUSTOMER_KEY)
             END as Merchant,
         CASE
             WHEN q.is_nc_merchant = 1 THEN (select city
                     from testprod.non_customer nc
                    where q.MERCHANT_CUST_KEY = nc.CUSTOMER_KEY)
             ELSE (select city
                     from prod.customer c
                    where q.MERCHANT_CUST_KEY = c.CUSTOMER_KEY)
             END as Merchant_City,
         CASE
             WHEN q.is_nc_merchant = 1 THEN (select state_code
                     from testprod.non_customer nc
                    where q.MERCHANT_CUST_KEY = nc.CUSTOMER_KEY)
             ELSE (select state_code
                     from prod.customer c
                    where q.MERCHANT_CUST_KEY = c.CUSTOMER_KEY)
             END as Merchant_St,
             q.is_nc_printer,
         CASE
             WHEN q.is_nc_Printer = 1 THEN (select customer_name
                     from testprod.non_customer nc
                    where q.Printer_CUST_KEY = nc.CUSTOMER_KEY)
             ELSE (select customer_name
                     from prod.customer c
                    where q.Printer_CUST_KEY = c.CUSTOMER_KEY)
             END as Printer,
         CASE
             WHEN q.is_nc_Printer = 1 THEN (select city
                     from testprod.non_customer nc
                    where q.Printer_CUST_KEY = nc.CUSTOMER_KEY)
             ELSE (select city
                     from prod.customer c
                    where q.Printer_CUST_KEY = c.CUSTOMER_KEY)
             END as Printer_City,
         CASE
             WHEN q.is_nc_Printer = 1 THEN (select state_code
                     from testprod.non_customer nc
                    where q.Printer_CUST_KEY = nc.CUSTOMER_KEY)
             ELSE (select state_code
                     from prod.customer c
                    where q.Printer_CUST_KEY = c.CUSTOMER_KEY)
             END as Printer_St,
             s.product_line_desc, s.part_master_desc, q.quote_date,
             q.is_order, q.order_nbr
       FROM testprod.quote q,
         testprod.spec s
       WHERE(s.spec_key(+) = q.spec_key)
       ORDER BY QUOTE_KEY;
    QuoteOutCur := LocalQuoteCur;
  END GetForSelect;
END QUOTE1_DBPKG;
Warning: Package body created with compilation errors
 
COMMIT
Commit complete
 
/
GRANT EXECUTE ON  testprod.QUOTE_DBPKG TO testprod_USER_ROLE
Grant succeeded
 
/
COMMIT
Commit complete
 
/
[+][-]12/16/03 08:30 AM, ID: 9950301Accepted Solution

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

Zone: Oracle Product Info
Tags: case, compilation, created, procedure
Sign Up Now!
Solution Provided By: tf842
Participating Experts: 1
Solution Grade: A
 
[+][-]12/16/03 02:21 PM, ID: 9952765Expert Comment

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.

 
 
Loading Advertisement...
20091021-EE-VQP-81