Quantcast
Channel: IBM Mainframe Computers Forums
Viewing all articles
Browse latest Browse all 8500

DB2 :: Variable for cursor names

$
0
0
Author: ravikumar15
Subject: Variable for cursor names
Posted: Sun Jul 17, 2016 7:08 am (GMT 5.5)

I have a requirement where I need to declare a cursor for the same table in two different conditions.

Condition 1:
With Where clause having only one column,

Condition 2:
When the date field in the input file is having value then include additional date field also in the where clause.

For this, I would like to pass the Cursor name to a variable and using that variable, declare the cursor after checking the date field from input file.

If the date field is blank declare, open, fetch, close Cursor-A
if the date field is non blank declare, open, fetch, close Cursor-B

Code:
If IN-DATE-1 = SPACES
   Move 'CURSOR-A' to WS-CURSOR-NAME
ELSE
   Move 'CURSOR-B' to WS-CURSOR-NAME

DECLARE :WS-CURSOR-NAME
where column-1 = :ws-column1

DECLARE :WS-CURSOR-NAME
where column-1 = :ws-column1
    and date-1 = :IN-DATE-1


Can the cursor name in DECLARE statement be a field which contains a value?

Is there any other option for this.

Any suggestion would be of great help.

Thanks in advance


Viewing all articles
Browse latest Browse all 8500

Trending Articles