Question: I am getting the following error. Getting the error at `SELECT CASE` statement.

> 
> PLS-00428: an INTO clause is expected in this SELECT statement
> 
> 
> 

```
FOR REMS IN cur_names LOOP

SELECT CASE   
        WHEN EXISTS (SELECT 1 
                     FROM SupplyTable 
                     WHERE FirstName = REMS.Names) 
        THEN 'Y' 
        ELSE 'N' 
    END AS rec_exists
FROM dual;

  IF rec_exists = 'Y' THEN
    FName := REMS.Names;
  ELSE
    FName := 'Gen';
  END IF;
END LOOP;

```

Answer: 
you can´t have a random select inside your pl sql code. It must be in a loop, cursor, with an into clause. Just include an into clause here. 

```
declare 
   v_value varchar2(1);
begin
...
FOR REMS IN cur_names LOOP

   SELECT CASE   
           WHEN EXISTS (SELECT 1 
                        FROM SupplyTable 
                        WHERE FirstName = REMS.Names) 
           THEN 'Y' 
           ELSE 'N' 
       END AS rec_exists
   INTO v_value 
   FROM dual;
   IF v_value = 'Y' THEN
      FName := REMS.Names;
   ELSE
      FName := 'Gen';
   END IF;
END LOOP;
...

```

or a loop

```
FOR REMS IN cur_names LOOP

   for i in 
   (   
       SELECT CASE   
           WHEN EXISTS (SELECT 1 
                        FROM SupplyTable 
                        WHERE FirstName = REMS.Names) 
           THEN 'Y' 
           ELSE 'N' 
       END AS rec_exists
       FROM dual
   )
   loop
      IF i.rec_exists = 'Y' THEN
         FName := REMS.Names;
      ELSE
         FName := 'Gen';
     END IF;
   end loop;
END LOOP;

```
You need to store the output somewhere , like a variable. `REC_EXISTS` is a column, so right after the select it no longer exists.

Try this:

```
declare rec_exists varchar2(1);;
FOR REMS IN cur_names LOOP
SELECT CASE   
        WHEN EXISTS (SELECT 1 
                     FROM SupplyTable 
                     WHERE FirstName = REMS.Names) 
        THEN 'Y' 
        ELSE 'N' 
    END into rec_exists
FROM dual;
  IF rec_exists = 'Y' THEN
    FName := REMS.Names;
  ELSE
    FName := 'Gen';
  END IF;
END LOOP;

```