I have a parameter coming into my package that has a value pertaining to a code I need to plug it into a where clause in a cusor.
According to one or all codes that is selected from a drop down list I need to use it in a where clause such as: 'where item_code in (code)'
I set up a code table for the drop down as follows.
If selection from dropdown is: The parameter coming into package is:
'ALL' 'AD', 'NB', 'VD', 'RF'
'AD' 'AD'
'NB' 'NB'
'VD' 'VD'
'RF' 'RF'
Below is part of the code:
CREATE OR REPLACE PACKAGE BODY UNRESLVD2 IS
PROCEDURE Create_AutoData ( a_code IN VARCHAR2 DEFAULT 'ALL') IS
CURSOR get_equal_recs_cur is
SELECT ACCOUNT,
TRANS_NUM,
DEPOSIT_DATE,
ITEM_CODE
FROM vw_trans_display,
WHERE vw_trans_display.ITEM_CODE IN < WHATEVER IS SELECTED FROM THE DROPDOWN VIA VARIABLE, a_code >
BEGIN
...
....
END
If 'ALL' is selected from the dropdown how can I send the string 'AD', 'NB', 'VD', 'RF' through the IN clause?
Should a decode be used here?
I tried:
where ( (DECODE(a_code,'ALL',(vw_trans_display.ITEM_CODE IN ('AD', 'NB', 'VD', 'RF' )), a_code))
but it did not work.
Thanks in advance for your help.
getjbb
According to one or all codes that is selected from a drop down list I need to use it in a where clause such as: 'where item_code in (code)'
I set up a code table for the drop down as follows.
If selection from dropdown is: The parameter coming into package is:
'ALL' 'AD', 'NB', 'VD', 'RF'
'AD' 'AD'
'NB' 'NB'
'VD' 'VD'
'RF' 'RF'
Below is part of the code:
CREATE OR REPLACE PACKAGE BODY UNRESLVD2 IS
PROCEDURE Create_AutoData ( a_code IN VARCHAR2 DEFAULT 'ALL') IS
CURSOR get_equal_recs_cur is
SELECT ACCOUNT,
TRANS_NUM,
DEPOSIT_DATE,
ITEM_CODE
FROM vw_trans_display,
WHERE vw_trans_display.ITEM_CODE IN < WHATEVER IS SELECTED FROM THE DROPDOWN VIA VARIABLE, a_code >
BEGIN
...
....
END
If 'ALL' is selected from the dropdown how can I send the string 'AD', 'NB', 'VD', 'RF' through the IN clause?
Should a decode be used here?
I tried:
where ( (DECODE(a_code,'ALL',(vw_trans_display.ITEM_CODE IN ('AD', 'NB', 'VD', 'RF' )), a_code))
but it did not work.
Thanks in advance for your help.
getjbb