Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

case select statements

Status
Not open for further replies.

muffntuf

MIS
Jan 7, 2003
155
US
does CR XI support a double or multiple case select statement?

For example:

Select year({hiredate})
case 1996:
select {salary}

case > 75000:

{Salary} * 1.07

Thanks!
 
Sure, I use parens:

Select year({SNAPSHOT_REFRESH_DETAILS.REFRESH_DATETIME})
case 1996:
(
select {SNAPSHOT_REFRESH_DETAILS.REFRESH_DETAILS}
case "hi": 12 * 1.07
case "bye": 13 * 1.07;
)
case 2005:
100

You can also use nested IFs.

-k
 
So we return to this Nested Case statement folks, here my new problem:

I need to use a nested case statement but look for values in a >, <, or = to situation. I seem to be erroring out on this:
Select year({Employee.Hire Date})
Case 1996:
(Select {Employee.Salary}
Case > 75000:
{Employee.Salary} * 1.1)

Got any suggestions - USING CRXI this time
 
Sure, post the error rather than just stating that you get one. Any tech suppport person would ask you this 1st off, please take the time to post the basics.

Try:

Select year({Employee.Hire Date})
Case 1996:
(Select {Employee.Salary} > 75000
Case true:
{Employee.Salary} * 1.1)

-k
 
That's interesting, I will propose this in class tomorrow to my students. Here's another one (okay I didn't write the material BO did. I can't figure out why a global variable isn't seen all the way through a formula.

the first formula is the standard hire year, salary, raise:
local numbervar employee_hire_year := year({Employee.Hire Date});
global numbervar cost_of_living_increase;
local currencyvar employee_salary := {Employee.Salary} * (1 + (cost_of_living_increase/100));

select employee_hire_year
case 1996:
if employee_salary > 75000 then
employee_salary * 1.1
else if employee_salary >= 35000 then
employee_salary * 1.08
else
employee_salary * 1.06
case 1997:
if employee_salary > 45000 then
employee_salary * 1.09
else
employee_salary * 1.07
case 1998:
if employee_salary > 55000 then
employee_salary * 1.09
else if employee_salary >= 30000 then
employee_salary * 1.06
else
employee_salary * 1.04
case 1999:
if employee_salary > 70000 then
employee_salary * 1.1
else
employee_salary * 1.05

the Cost of Living is declared in another formula with a global variable and called in this formula. Here is the Cost of Living Variable:

global numbervar cost_of_living_increase := 2

If you use the variable after declaration in the first formula, instead of in the employee_salary variable, then its like CR doesn't see it. For example, after all variables are declared and the cost_of_living_increase is assigned .02

select employee_hire_year
case 1996:
if employee_salary > 75000 then
(employee_salary * 1.1)*cost_of_living_increase
else if employee_salary >= 35000 then
employee_salary * 1.08 *cost_of_living_increase
etc.

Got any clues?

Thanks
muffntuf
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top