Ideally I would like to do:

IF SELECTION_TERRITORY > 0 THEN
DECLARE C1 CURSOR FOR
SELECT ... some stmt
OPEN C1 ;
ELSE
DECLARE C2 CURSOR FOR
SELECT .... some stmt
OPEN C2 ;
END IF ;

But the IF statement can not be called before DECLARing a cursor.

-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of rob@xxxxxxxxx
Sent: Friday, July 31, 2009 8:35 AM
To: Midrange Systems Technical Discussion
Subject: RE: Stored Procedure with different SUMs - STATIC SQL

I was thinking that maybe a CASE clause may work but case is often based

on the contents of column - not a selection or host variable.

For example if you have a table that looks like this
item
sales2009
sales2008
sales2007
...
you want to do something like
case :hostvar
when '2009' then sum(sales2009)
when '2008' then sum(sales2008)
end;

I am not sure this can be done. Has your DBA heard of something called
"Third Normal Form"?

Rob Berendt

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.