Windows 11 | Remote Server Administration Tools (RSAT)

A wonderful article about installing RSAT (Remove server administration tools) on Windows 11 is available at How To Install RSAT On Windows 11 PCs HTMD Blog (

I would like reiterate something Anoop has mentioned in his article. If you are using Microsoft SCCM or Windows Update Services (WU), then you must enable the local group policy as he has mentioned clearly in his post.

The image attached by Anoop could be bit confusing for the local group policy setup, hence I am uploading one with better visibility. The path is “Computer Configuration->Administrative Templates->System” & you need to open “Specify settings for optional component installation and component repair”

No need to reboot the computer for installing RSAT components. Follow Anoop’s thread and be a happy Administrator!

Linux | File Cleaner | bash script

Recently we setup a Linux server for keeping backups & decided not to use certain switches while the backups were synched from Windows machines. This created an additional situation like maintaining the storage space based on different business requirements and using our own solutions. So the following script was developed. Please note, this script has been tested on CentOS/RHEL/OEL 7 environment & executed with root privileges.


# Cleanup tool for Linux Samba Server
# Rajesh Thampi
# Date: Sep 2021
# Instructions
# Copy the script to a file with .sh extension
# Make it executable (eg: chmod +x
# Execute! (eg:./ 1>filecleaner.log 2>filecleaner.err
# And be careful :)

function purgeit(){
# local DIRNAME="$1"
# local FILETYPE="$2"

cd "$1"
echo "Entered Directory: ${PWD}"
#Check whether $3 number of files matching the patterns provided by $2 are present those were created within $4 days, then delete all files older than $4 days
if [ $(find -maxdepth 1 -name "$2" -type f -mtime -"$4" | wc -l) -ge $3 ]; then
local OBSFILECNT=$(find -maxdepth 1 -name "$2" -type f -mtime +"$4" | wc -l)
echo "There are ${OBSFILECNT} files & will be purged"
local obsfiles=$(find -maxdepth 1 -name "$2" -type f -mtime +"$4")

#The below loop is ONLY for logging purpose
#We'll delete all files matching the pattern in a single line command using "find"

        if [ $OBSFILECNT -gt 0 ]; then
        echo "Below Files will be deleted"
        for eachfile in "$obsfiles"
                echo "$eachfile"
                #find and delete will eliminate the need to treat files with space and other escape characters in the filenames.
                find -maxdepth 1 -name "$2" -type f -mtime +"$4" -exec rm -rf {} \;

#Call the function passing four variables: path, type of the files to purge, number of files to keep & age of the files
#those need to be deleted

#syntax: purgeit "/backup/server_sql" ("*.txt" OR "my*.php" OR "*" OR "*.*") 4 5
#example: purgeit "/backup/server_sql" "*.zip" 4 5
#You can call this function N number of times passing different paths and other values

Now let us see the logic in details.

Consider you have a path “/backup/server_sql” where your Microsoft SQL Server is uploading a full backup daily. As we are synching the backup files using ROBOCOPY from the Windows server without mirroring, the daily full backup files will start mounting in the Linux files server. Then we came up with a business plan to:

  • Keep minimum 4 number of most recent full backups for the SQL server in the Linux path those were created within last N number of days. If there are no files for last N days found, existing files will not deleted (gives an opportunity to investigate why there are no files uploaded to Linux file server)
  • Delete files those are 5 days or older from the Linux path after insuring minimum N number of files are within the repository.
  • Combined with a function send alert emails, this small snippet could function as both a storage maintenance and monitoring tool.

Interested about including email alerts? Let us know and will share the additional code with you exclusively.

Oracle Application | “apps” user account is locked!

Today while running automatic configuration on the Application Tier, I entered the “apps” user password wrong! After the automatic configuration completed, having errors, I couldn’t start the Application tier.

It just said invalid password or database is not open.

Later after going through adautoconfig log files, I could see a number of failed connection attempts stating the account was locked, however I least expected this account to be “apps” (issues that one runs into when not properly exposed to the stack)

I opened SQL from application user and tried to login as apps/apps & was told the account was locked. I unlocked the apps account and ran the autoconfig once again, this time supplying the correct password. Everything went smooth and I was able to start the Application Tier.

So this is what happened. I supplied a wrong password for autoconfig & consecutive attempts to connect database from different scripts used the same credentials & after 10 failed attempts the account got locked up! causing rest of the issues.

So, be very careful when you are supplying apps password to scripts. As I am not an APPS DBA, it took me a while to figure this one out!

Optionally you may apply a better solution as mentioned here. Regardless, just be careful when you are supplying “apps” user password

Windows | Search & WIFI cannot type

There are situations, especially while using Windows 10 gen OS (Windows 2016+ Servers included) a user might not able to type inside

  • Windows Search Textbox
  • WIFI Password Textbox

For some strange reasons, typing inside these text boxes are supported by “CTF Loader”(C:\Windows\System32\ctfmon.exe)” & that is loaded into computer’s memory normally after a restart/reboot.

This is facilitated by one of the Windows Tasks & certain attempts like using KMSPICO tool to activate Microsoft software, which is ILLEGAL and many times breaks this Task.

So, how do we fix it? There are two different approaches

  • Rebuild the Task
  • Using Registry

We’ll see both methods in detail now.

1# Rebuild the Task

If the KMSpico tool or other reason corrupts the Task, you will not find any entries in the folder “TextServicesFramework”

Edited image for demo.

when an intact task should look like below

So how do we recreate this task, that is a custom handler?

Browse to “C:\WINDOWS\System32\Tasks\Microsoft\Windows\TextServicesFramework” & check whether you can find a file “MsCtfMonitor” inside the folder. If you cannot find the file in this folder, copy the file from another Windows machine that has the same version.

Copy the file to desktop and add the extension “.xml” to it.

Opening the file with notepad or another text editor should look like the following:

Go back to Task Scheduler and right click on “TextServiceFramework” and select “Import Task”

Point to the xml file that you have created in the desktop & apply. This should create a new task under the folder “TextServiceFramework”

Restart and confirm you can type in the search box and WIFI password text boxes. Alternatively you can use the Task Manager to check whether “CTF Loader” has been loaded.

2# Registry

Remember, registry entries might get removed through updates/new versions. However, as a temporary measure you can use the following hack to address the keyboard issues.

Make a full backup for the Registry. You must know, tampering registry could force you to a fresh installation of the OS!

Once a full backup for the Registry is made, browse to “Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run”

Create a new string key and call it anything that you want. Example

I have called the string key as “CTFLoader” and for the Value make sure to enter “ctfmon”=”CTFMON.EXE”

Reboot the computer and check whether the typing issues resolved. Alternatively use Task Manager to check whether CTF Loader has been loaded.

Although both fix the typing issues, the right way is to recreate the missing Task. Choose wisely & don’t pirate! We know many interesting software are pricely and many of us cannot afford them. There are free alternatives for maximum pirated software like

And many more software that you need for Office/School/Home works! Piracy not only breaks the businesses that develop them, helps cyber criminals to unleash attacks like Ransomware through serial number generators and patches.

Hope this has helped you today.

Windows 10 | Windows cannot connect to the printer

There are times when you come across the error “Windows cannot connect to the printer” (error 0x000003e3) while trying to connect to a shared printer that is connected to another Windows 10 computer.

Quite possible that the drivers installed on the source machine is either not compatible with the client/target machine or not getting copied to the target machine. Now, install the correct version of printer driver to the target machine and try to connect again. There could be few other items you must check and insure for a successful connection.

  • Make sure both the computers network property shows the connection as either domain or private.
  • Make sure you have File & Printer sharing enabled for the network

That’s all folks

RMAN on Windows | Backup & Restore 11g R2 database

11g R2? too late to post anything for 11g? Wait, there are thousands of Businesses still using Oracle database 10g. So let us see how RMAN could be simplified on Windows. I hardly see many articles explaining such for Windows platform in general.

Considering you have 11g database already installed & setup for Archive logging, we’ll start by setting up RMAN backup first, then try a restore routine on a different sever.

Like cron jobs on Linux environment, for Windows we will use Task Scheduler for RMAN backups. Here are couple of batch files we will be using for making RMAN backup on Windows.

crosscheck archivelog all;
crosscheck backup;
DELETE NOPROMPT archivelog all completed before 'sysdate-7';
backup current controlfile format 'D:\RMAN_BACKUP\bkpcontrol_file.ctl_%d_%T'               ;

Save this script as “rman_backup.cmd”. You can save it with any other name ending with .cmd or .bat extension. Make sure you change the name in the next script incase if you choose a name other than “rman_backup.cmd”. Please note, I am taking backup on “D:\RMAN_BACKUP” folder, you should change “D:\RMAN_BACKUP” with the exact location that is used for the backup!

Now, we will create another cmd file that will call the above script.

@echo off
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a%%b)
:: echo %mydate%_%mytime%

set filename="D:\RMAN_BACKUP\logs\%mydate%_%mytime%_rman_backup.log"
:: echo %filename%

rman target / nocatalog cmdfile='D:\scripts\rman_backup.cmd' log='%filename%'

Once again you can save this file with anytime, provided the extension is either .cmd or .bat. I saved this cmd file as “callrman.cmd”

Make sure the path ” D:\RMAN_BACKUP\logs” or equivalent exists prior running the scripts.

Now fire up Windows Task scheduler and create a basic job

That’s all. Everyday, at a said time, RMAN backups will be created and kept in the destination folder. We are using 7 days retention policy with the script file, so on the 8th day obsolete backups will be purged. Depending upon the disk space available, you should adjust the retention policy for your backups. Don’t forget to copy those backup pieces to an external medium to insure maximum availability during a crisis.

That completes the simplest form of Oracle RMAN backups on Windows platform.

RMAN Restore

Currently we are discussing about restoring the RMAN backup to same version of Oracle database. If you want to restore RMAN backup to a higher version of Oracle database, it will be an entirely different exercise.

RMAN backups are the fastest, easiest incase if you are doing it right. No hassles like creating tablespaces, schemas and then waiting hours for the import process to complete! The biggest size of the database I ever dealt with is 550GB and a server with 2×4 core processors, 16GB total memory restores the 140GB backup in less than 1.5 hours. I suggest you to start using RMAN backups the soonest possible regardless whether your database is just few megabytes in size.

Today we will see how to restore RMAN backup from Server A to Server B, ie, to a different physical server with a different database name.

It might sound bit unethical to ask you to create a new database using Oracle database creation wizard for this purpose, however this is what we will do for this exercise. This will save us some time figuring out setting up many other parameters for the new database at later stages.

So let us start.

Start DBCA and create a database with a database name that you prefer for the purpose, for eg: “ORCL”

Once the database created, shut it down & delete all the datafiles from the data store. For example, I had all my data files in the folder C:\oracle\oradata\orcl, where orcl is the database name!

Now copy the RMAN backups from Server A to Server B. I’ve copied only one day backups from Server A to Server B and make a note of the exact location where you copied the backup files. In my case, I copied the files to “C:\RMAN”

From an elevated command prompt start SQLPLUS as sysdba & start the database in non mounted mode.

Now, start another elevated command prompt and connect to RMAN in Auxiliary mode, for duplication of the database.

We are all set to restore the RMAN backup to Server B now. However, there are few things we have to insure to make a successful restoration. For example renaming the datafiles. Based on the new datastore location where you are restoring the database files, each data file should be renamed. Please refer the below sample script for the same.

duplicate database to "ORCL" backup location 'C:\RMAN' nofilenamecheck
) SIZE 1000M ,
) SIZE 1000M ,
) SIZE 1000M ,
) SIZE 1000M ;

As I am duplicating the database to existing one, I don’t have to go through the tedious process of changing the dbid or database name etc. Once the restore is done, all I need is to disable the archive logging and go online! We will see those in next few steps.

Please give attention to “db_file_name_convert“, Server A had the datafiles in the path “D:\oracle\oradata\PROD” and the Server B, we will be restoring the datafile to C:\oracle\ordata\orcl folder. So we must mention those changes here in the script. The same way we need to rename the logfiles and locations also. I hope the above script is self explanatory on that regard.

You may not need all those channel allocation for a small database, please adjust the number of cannels allocated as per your requirements. Give a try with less or more number of channels incase if you want to learn what happens :)

Execute the above script from the RMAN prompt.

If there are no errors, based on the size of the database & hardware resources RMAN will return to the prompt once the activities are finished.

Before doing anything else, we need to insure that the Archive logging is disabled for the newly restored database. Rush to the previous SQLPlus session that you started with nomount. This session is already disconnected, hence reconnect and shutdown immediate.

Now start the database in mount state and disable the archive logging.

Shutdown the database and restart normally.

That’s all, your Server B “orcl” has all the data from Server A “PROD” database now. If this is a production recovery, you can change the database name using “NID” utility, that is supported from Oracle database 9i onwards. Hope this helps few Oracle database beginners out there.

As we have restored full database with archive logs, there is no need to restore logs. Cross verify the database details

Cheers guys!

Oracle Application R12 | Using Microsoft Edge Chrome for versions 11 & 12.0.xx

Updated on 8th October 2021 for Microsoft Edge Version 94.0.x.x & for Windows 11 that comes without Internet Explorer (or it doesn’t allow you to start Internet Explorer)

A much easier method is available with versions later than the one I used earlier.

Step# 1. Go to Edge settings (type edge://settings in the address bar and select “Default Browser”

Change “Allow sites to be reloaded in the Internet Explorer mode” to “Allow”, that will require you to restart the browser. Please restart

Step# 2. Now enter the address of your Oracle Application in the address bar and wait for the login page to load. Once loaded, click on the “three dots” menu by the extreme right of the browser and select “Reload in Internet Explorer mode”

This will open another dialog box as seen with the above image. Toggle “Open this page in Internet Explorer mode next time” and click “Done” button, that will produce more notifications like the one you could see with the below image.

It asks you to leave the Internet Explorer mode and another button “Show in toolbar”. This is an interesting button, clicking that starts showing a small tool button in the tools area and the button will reload the current page in “Internet Explorer mode”.

That’s all. Just click the toolbar button and your Oracle Application login page will be loaded in “Internet Explorer mode” immediately.

Toggling the switch to “Open this page in Internet Explorer mode next time” in the “Step# 2” adds an entry to “Internet Explorer mode pages” area for your current page and the entry is valid for next 30 days. Microsoft is expecting you to modernize your “page” within those next 30 days ;). Once this entry expires, you must get the “Open this page in Internet Explorer mode next time” dialog box once again.

October 8, 2021 update ends here.

After 25 years ever since it was launched, Windows 11 will be the first OS that is not shipping with Internet Explorer.

How does this matter to Businesses those use Oracle Application versions 11 & 12.0.xx? Well, currently Internet Explorer is the only one browser that allows to load Oracle JRE (NPAPI client) for Oracle Forms, on which much of the Oracle module rely.

Oracle Applications has patched the latest releases with a technology called JWS (Java Web Start), that let’s the users to download a jnlp file from the application and Oracle Java Run Time to start in desktop mode (without being loaded in a browser session) loading Oracle Forms. Well, this enhancement is not available for Application versions 11 & 12.0.xx

Microsoft was expecting a huge cry from the Businesses that use Oracle Applications/legacy implementations those cost millions of dollars and fine tuned for Internet Explorer. Cutting these businesses could mean loads for Microsoft, So they have integrated “IE Mode” into their chromium based “Edge browser”, which is the default browser on Windows 11. IE Mode makes Edge Chrome to “act” as if it were Internet Explorer for legacy Web based applications & loads NPAPI clients like JRE.

Today let us see how to configure Microsoft Edge Chrome for Oracle Applications.

Start Microsoft Edge Chrome & open “Settings”

Click on Default Browser & spend a moment to check currently set options.

Let us change few of those settings like shown below.

Let Internet Explorer open sites in Microsoft Edge -> Change to Allow

Allow sites to be reloaded in Internet Explorer mode ->Change to “Allow”. This will require you to restart the browser.

You must add the sites those you want to open in IE mode by clicking “Internet Explorer mode pages” Add button. Such pages will have maximum 30 days validity. Without, JRE will not load and will prompt you to download it from the default location.

Now, let us click the restart button & give it a try.

That’s all folks.

rsync | Excluding a subdirectory/folder

We’ve Oracle RMAN backups copied to a remote server everyday & those chunks are once again copied to a removable media to “avoid”, disasters.

After a revamp of backup path, I needed to adjust the rsync command within a shell script to exclude a folder from the source. Misunderstanding the instructions, the new modifications made the shell script to copy the backup chunks twice on the removable media!

Let us see what I did initially that caused the duplication

[root@orcl DAILYBKP]# cd /u03
[root@orcl u03]# mkdir -p folder1/erp/RMAN/DAILYBKP
[root@orcl u03]# mkdir -p folder1/sf1
[root@orcl u03]# mkdir -p folder1/sf2
[root@orcl u03]# mkdir -p folder1/sf3
[root@orcl u03]# mkdir -p folder2
[root@orcl u03]# touch folder1/erp/RMAN/DAILYBKP/r1.txt
[root@orcl u03]# touch folder1/erp/RMAN/DAILYBKP/r2.txt
[root@orcl u03]# touch folder1/sf2/r1.txt
[root@orcl u03]# touch folder1/sf3/r1.txt
[root@orcl u03]# rsync -avz --exclude '/u03/folder1/erp' /u03/folder1 /u03/folder2
sending incremental file list

The above example demonstrates the mistake that I made while “excluding” a folder from the source. The correct method to exclude a subdirectory or folder was as below

[root@orcl u03]# rsync -avz --exclude 'erp/' /u03/folder1 /u03/folder2
sending incremental file list

sent 263 bytes  received 74 bytes  674.00 bytes/sec
total size is 0  speedup is 0.00
[root@orcl u03]# cd folder2
[root@orcl folder2]# ls -ltrh
total 4.0K
drwxr-xr-x 5 root root 4.0K Aug 12 09:39 folder1
[root@orcl folder2]# cd folder1
[root@orcl folder1]# ls -ltrh
total 12K
drwxr-xr-x 2 root root 4.0K Aug 12 09:39 sf1
drwxr-xr-x 2 root root 4.0K Aug 12 09:40 sf2
drwxr-xr-x 2 root root 4.0K Aug 12 09:41 sf3
[root@orcl folder1]#

All I needed was to just mention the name of the subfolder that I needed to exclude, not the whole path. I’ve limited exposure to Linux and much of the OS activities are initiated on demand. This causes some interesting situations like the one above & definitely helps to learn something new!

Oracle 19c | Applying Patch

Much of the times I use latest Oracle technologies for learning & they hardly make to any of the PRODUCTION environments those I support at work. Recently I wanted to see how to patch Oracle 19c installation on Windows and to be frank, it was buttery smooth.

Let us quickly see how to apply a patch to a Windows installation of Oracle 19c database.

Shutdown all instances & Windows services for Oracle. Make sure you have taken adequate number of backups for the database(s).

Check you computer’s PATH variable. Insure you have %ORACLE_HOME%\perl\bin, in my case “D:\Oracle\19c\perl\bin” as the first entry for PERL.

This is how the PATH information before I make the above changes to it.

Here 11g 32Bit client is the first Oracle software in the PATH, we will modify it like below

Once the patching done, you can rollback the PATH variable according to your requirements.

Visit Oracle support and download the patch, the latest patch for Oracle Database 19c is “32409154”. Patch is only available to customers with a valid support contract.

Extract the archive.

I’ve extracted the archive within the Download folder and the path is


Now open an elevated command prompt and switch to the folder with patch number as it’s name. Check the below image for details.

Now we are ready to apply the patch.

Call the opatch utility from here, like given example below.

Microsoft Windows [Version 10.0.19043.985]
(c) Microsoft Corporation. All rights reserved.

C:\Oracle19c_Patch\p32409154_190000_MSWIN-x86-64\32409154>d:\Oracle\19c\OPatch\opatch apply
Oracle Interim Patch Installer version
Copyright (c) 2021, Oracle Corporation.  All rights reserved.

Oracle Home       : d:\Oracle\19c
Central Inventory : C:\Program Files\Oracle\Inventory
   from           :
OPatch version    :
OUI version       :
Log file location : d:\Oracle\19c\cfgtoollogs\opatch\opatch2021-06-23_10-47-41AM_1.log

Verifying environment and performing prerequisite checks...
OPatch continues with these patches:   32409154

Do you want to proceed? [y|n]
User Responded with: Y
All checks passed.

Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.
(Oracle Home = 'd:\Oracle\19c')

Is the local system ready for patching? [y|n]
User Responded with: Y
Backing up files...
Applying interim patch '32409154' to OH 'd:\Oracle\19c'
ApplySession: Optional component(s) [ oracle.assistants.usm, ] , [ oracle.rdbms.ic, ] , [ oracle.rdbms.tg4ifmx, ] , [ oracle.has.deconfig, ] , [ oracle.swd.oui, ] , [ oracle.has.cfs, ] , [ oracle.rdbms.tg4tera, ] , [, ] , [, ] , [ oracle.rdbms.tg4msql, ] , [ oracle.ons.daemon, ] , [ oracle.options.olap.awm, ] , [ oracle.rdbms.tg4db2, ] , [ oracle.assistants.asm, ] , [ oracle.usm, ] , [ oracle.swd.oui.core.min, ] , [, ] , [ oracle.options.olap, ] , [, ] , [ oracle.tfa, ] , [ oracle.has.cvu, ] , [ oracle.rdbms.tg4sybs, ]  not present in the Oracle Home or a higher version is found.

Patching component oracle.sdo,

Patching component oracle.rdbms.rman,

Patching component oracle.aspnet_2,

Patching component oracle.dbjava.ic,

Patching component oracle.ons,

Patching component oracle.ntoramts,

Patching component oracle.rdbms.dbscripts,

Patching component oracle.nlsrtl.rsf,

Patching component,

Patching component oracle.rdbms,

Patching component oracle.blaslapack,

Patching component oracle.rdbms.oci,

Patching component oracle.assistants.acf,

Patching component oracle.duma,

Patching component oracle.sdo.locator.jrf,

Patching component oracle.tfa.db,

Patching component,

Patching component oracle.ctx.atg,

Patching component oracle.xdk.rsf,

Patching component oracle.precomp.common,

Patching component oracle.dbjava.jdbc,

Patching component oracle.rdbms.hsodbc,

Patching component oracle.sqlplus.ic,

Patching component oracle.oracore.rsf,

Patching component oracle.rsf,

Patching component oracle.precomp.common.core,

Patching component,

Patching component oracle.precomp.lang,

Patching component oracle.install.deinstalltool,

Patching component oracle.ctx,

Patching component oracle.dbjava.ucp,

Patching component oracle.javavm.client,

Patching component,

Patching component oracle.ntoledb.odp_net_2,

Patching component oracle.rdbms.util,

Patching component oracle.rdbms.lbac,

Patching component oracle.usm.deconfig,

Patching component oracle.assistants.server,

Patching component oracle.rdbms.deconfig,

Patching component oracle.ntoledb,

Patching component oracle.has.common,

Patching component oracle.assistants.deconfig,

Patching component oracle.ldap.rsf,

Patching component oracle.ovm,

Patching component oracle.has.db,

Patching component oracle.rdbms.plsql,

Patching component oracle.precomp.rsf,

Patching component oracle.xdk.xquery,

Patching component oracle.javavm.server,

Patching component oracle.xdk,

Patching component oracle.dbdev,

Patching component oracle.sdo.locator,

Patching component oracle.rdbms.install.plugins,

Patching component oracle.rdbms.olap,

Patching component oracle.rdbms.scheduler,

Patching component oracle.rdbms.rsf.ic,

Patching component oracle.ldap.owm,

Patching component oracle.rdbms.rsf,

Patching component oracle.mgw.common,

Patching component,

Patching component oracle.oraolap,

Patching component oracle.clrintg.ode_net_2,

Patching component oracle.rdbms.dv,

Patching component oracle.has.rsf,

Patching component oracle.odbc.ic,

Patching component oracle.sqlplus,

Patching component oracle.has.common.cvu,
Patch 32409154 successfully applied.
Log file location: d:\Oracle\19c\cfgtoollogs\opatch\opatch2021-06-23_10-47-41AM_1.log

OPatch succeeded.

As usual, based on your computer’s hardware capabilities, the patch would finish sooner or later. There will be 2 prompts those you need to say Yes in order to progress the patching.

Simple & neat right? Share your experience in the comments area.

Oracle PL/SQL | Exiting without executing rest of the code block

One of the major confusions for a PL/SQL programming beginners is how to exit a code block when a specific exception happens. Today we will see how we can handle these situation using user defined exceptions.

A developer can define as many exceptions for the code block and raise them as and when needed, than the default exception block for a BEGIN..END; block

Here I am trying to explain how a PL/SQL developer could exit the execution as soon as the first exception happens.


    l_number NUMBER := 11;
    myexp EXCEPTION;
        IF l_number = 10 THEN
            RAISE myexp;
        END IF;
        WHEN myexp THEN
            dbms_output.put_line('Okay, let us exit');

        dbms_output.put_line('Looks like there were no exceptions, let us show this!');

The above example is trying to demonstrate how the exceptions are handled by dividing the code into multiple BEGIN..END blocks. So here I am doing a check whether the “l_number” is 10 and to raise an user defined exception and by merely calling RETURN exit the complete PL/SQL block! As simple as it looks here.

Give it a try by change the l_number value to 10 at the declaration level and see yourself. Happy coding!