Doing an ELSE CASE within a CASE

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
datastage
Participant
Posts: 229
Joined: Wed Oct 23, 2002 10:10 am
Location: Omaha

Doing an ELSE CASE within a CASE

Post by datastage »

In UV BASIC the case syntax is:

BEGIN CASE
CASE expression
statements
[CASE expression
statements
.
.
.
]
END CASE



In a psuedocode sense I want to have an ELSE after my CASE's and before the END CASE.

What is the best way to approach this. At the moment I'm working on a routine and want to pass an error message to Ans I fail to get a match on my case comparisons. I thought maybe I could set Ans to my error message before my CASE, but there are other places afterwards I want to have error handling, so I'd still need a way to know I didn't have a case match and to exit the routine there with my error message.

Probably easy, but it's been a long day.

Thanks,
Byron Paul
WARNING: DO NOT OPERATE DATASTAGE WITHOUT ADULT SUPERVISION.

"Strange things are afoot in the reject links" - from Bill & Ted's DataStage Adventure
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Don't you just simply setup an @TRUE case at the end as a catch all? Whatever falls into it is the 'else' you are looking for, I believe.
-craig

"You can never have too many knives" -- Logan Nine Fingers
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

Craig is correct.

Code: Select all

begin case
  case x=1
    stmt1
  case y=1
    more stmt
  case @true
    stmt3
end case
Mamu Kim
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

I once knew a programmer who did this.

Code: Select all

Equate OTHERWISE Lit "CASE 1"

BEGIN CASE
   CASE expr1
      statements
   CASE expr2
      statements
         :
   OTHERWISE
      statements
END CASE
Unfortunately the formatter doesn't know about it, so formats the OTHERWISE line incorrectly, which was subsequently adjusted manually.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

Ray

I used to do this:

Code: Select all

Otherwise = @true

Begin case
  case x=1
  case x=2
  case Otherwise
end case
Reads nice.
Mamu Kim
Post Reply