Question has been PAQed and 500 points refunded.
Yensidmod
EE Moderator
Main Topics
Browse All Topicsoracle 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
/
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: tf842Posted on 2003-12-16 at 08:30:30ID: 9950301
I answered question by opening the local cursor for the select statment in a string/varchar2. Therefore, I will request it be closed w/ the following answer:
I declared my_sql as varchar2(15000)
then set my_sql equal to the entire select clause, including where, from and order by
my_sql := 'This was a very long string' Note: this was a very long string and I will break it into seperate := segments later
open localQuoteCur for my_sql
quoteoutcur:=localquotecur
That was all it took to compile and subsequently be able to run it from vb.net.
Perhaps this will help someone else
sami