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
/