Question : oracle pl/sql

i am getting subquery not allowed.

Can't i use the subquery in case statement.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
BEGIN
      
         CASE WHEN 
           P_PROGRAM_ID IN (SELECT   PROGRAM_ID FROM   LAYER1_PROGRAM WHERE PROGRAM = 'MSP/DMX')  AND
              TDP_LOAD_SUMMARY_REC.Customer IN
                      ('CNI-CD',
                       'CNI-00',
                       'CNI-TC',
                       'CNI-M',
                       'CNI-RH',
                       'CNI-XC',
                       'CNI-NP',
                       'CNI-RT')
         THEN
            SELECT   WAVELENGTH_TYPE_ID
              INTO   P_WAVELENGTH_TYPE_ID
              FROM   LAYER1_WAVELENGTH_TYPE
             WHERE   WAVELENGHT_TYPE_NAME = TDP_LOAD_SUMMARY_REC.Customer;
         ELSE
            P_WAVELENGTH_TYPE_ID := NULL;
         END CASE;
      EXCEPTION
         WHEN NO_DATA_FOUND
         THEN
            P_WAVELENGTH_TYPE_ID := NULL;
      END;

Answer : oracle pl/sql

Sub queries can only be used in SQL statements.  Since this case statement is in PL/SQL not regular SQL, you cannot do it.

Either select the id into another variable or somehow join the selects into a single select statement ot return the desired type_id.

What does the following return:

SELECT   WAVELENGTH_TYPE_ID
              INTO   P_WAVELENGTH_TYPE_ID
              FROM   LAYER1_WAVELENGTH_TYPE
             WHERE   WAVELENGHT_TYPE_NAME = TDP_LOAD_SUMMARY_REC.Customer and
TDP_LOAD_SUMMARY_REC.Customer IN
                      ('CNI-CD',
                       'CNI-00',
                       'CNI-TC',
                       'CNI-M',
                       'CNI-RH',
                       'CNI-XC',
                       'CNI-NP',
                       'CNI-RT')
and
P_PROGRAM_ID IN (SELECT   PROGRAM_ID FROM   LAYER1_PROGRAM WHERE PROGRAM = 'MSP/DMX');
Random Solutions  
 
programming4us programming4us