Question: I want to drop some users in Oracle DB using sqlplus but I am getting error:

```
SQL> DROP USER test CASCADE;
DROP USER test CASCADE
*
ERROR at line 1:
ORA-01940: cannot drop a user that is currently connected

```

I followed the link in SO to find out the sessions - [Dropping a connected user from an Oracle 10g database schema](https://stackoverflow.com/questions/85804/dropping-a-connected-user-from-an-oracle-10g-database-schema)

But when I ran the command I am not getting any results:

```
SQL> select sid,serial# from v$session where username = 'test';

no rows selected

```

Please help me how to drop users in this case.

Answer: 
Issue has been fixed using below procedure :

```
DECLARE
  v_user_exists NUMBER;
  user_name CONSTANT varchar2(20) := 'SCOTT';
BEGIN
  LOOP
    FOR c IN (SELECT s.sid, s.serial# FROM v$session s WHERE upper(s.username) = user_name)
    LOOP
      EXECUTE IMMEDIATE
        'alter system kill session ''' || c.sid || ',' || c.serial# || ''' IMMEDIATE';
    END LOOP;
    BEGIN
      EXECUTE IMMEDIATE 'drop user ' || user_name || ' cascade';
      EXCEPTION WHEN OTHERS THEN
      IF (SQLCODE = -1940) THEN
        NULL;
      ELSE
        RAISE;
      END IF;
    END;
    BEGIN
      SELECT COUNT(*) INTO v_user_exists FROM dba_users WHERE username = user_name;
      EXIT WHEN v_user_exists = 0;
    END;
  END LOOP;
END;
/

```
go to services in administrative tools and select oracleserviceSID and restart it