Category Archives: Oracle

Part 9 – Building Oracle 12c development suite – Media packages required for installation of Oracle RDBMS 12c

Part 9 – Building Oracle 12c development suite.
Media packages required for installation of Oracle RDBMS 12c

Oracle Corporation provides the ability for developers to create a complete development suite on their personal windows desktop or laptop without requiring the expensive equipment required for a true production system. This article outlines the process of downloading the media required for installation of Oracle 12c RDBMS in a RHEL 6.5 environment.
NOTE: This process can be used for most Linux installations, regardless of original company or organization providing the base Linux OS.

1. Logon to your Windows desktop/laptop as an administrator and open Oracle VirtualBox.
2. Open an internet browser and download the following files from www.oracle.com and place them in the directory /opt/app/oracle_software.

p17694377_121020_Linux-x86-64_1of8.zip
p17694377_121020_Linux-x86-64_2of8.zip
p17694377_121020_Linux-x86-64_3of8.zip
p17694377_121020_Linux-x86-64_4of8.zip
p17694377_121020_Linux-x86-64_5of8.zip
p17694377_121020_Linux-x86-64_6of8.zip
p17694377_121020_Linux-x86-64_7of8.zip
p17694377_121020_Linux-x86-64_8of8.zip

3. Change directory to /opt/app/oracle_software with the command “cd /opt/app/oracle_software”

[root@OEL65 ~]# cd /opt/app/oracle_software/
[root@OEL65 oracle_software]#

4. Extract the zip files with the following command: “find . -name “*.zip” -exec unzip {} \;”

[root@OEL65 oracle_software]# find . -name “*.zip” -exec unzip {} \;
[root@OEL65 oracle_software]#

5. NOTE: This is a base version of the software and requires additional patches to bring it to current date.
6. This completes the setup of the VM network.

Larry Catt, OCP

Part 8 – Building Oracle 12c development suite – Library setup for Oracle Enterprise Linux 6.5 for Oracle RDBMS 12c

Library setup for Oracle Enterprise Linux 6.5 for Oracle RDBMS 12c

Oracle Corporation provides the ability for developers to create a complete development suite on their personal windows desktop or laptop without requiring the expensive equipment required for a true production system. This article outlines the process for configuration libraries for an Oracle Enterprise Linux 6.5 installation in preparation for installation of Oracle 12c RDBMS.
NOTE: This process can be used for most Linux installations, regardless of original company or organization providing the base Linux OS.

1. Logon to your Windows desktop/laptop as an administrator and open Oracle VirtualBox.
2. Logon to your Linux VM as the root user.
3. Change directory to your yum repository with command: “cd /etc/yum.repos.d”

[root@oel65 ~]# cd /etc/yum.repos.d
[root@oel65 yum.repos.d]#

4. Extract the repository from the oracle public yum website with the command: “wget http://public-yum.oracle.com/public-yum-ol6.repo”

[root@OEL65 yum.repos.d]# wget http://public-yum.oracle.com/public-yum-ol6.repo
–2015-04-12 18:49:53– http://public-yum.oracle.com/public-yum-ol6.repo
Resolving public-yum.oracle.com… 70.186.29.33, 70.186.29.58
Connecting to public-yum.oracle.com|70.186.29.33|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 5046 (4.9K) [text/plain]
Saving to: “public-yum-ol6.repo.1”

100%[======================================>] 5,046 –.-K/s in 0s

2015-04-12 18:49:53 (225 MB/s) – “public-yum-ol6.repo.1” saved [5046/5046]

[root@OEL65 yum.repos.d]#

5. Edit the yum repo file with appropriate values with the following perl command: “perl -pi.bak -e ‘s/enabled=0/enabled=1/g’ /etc/yum.repos.d/public-yum-ol6.repo”

[root@OEL65 yum.repos.d]# perl -pi.bak -e ‘s/enabled=0/enabled=1/g’ /etc/yum.repos.d/public-yum-ol6.repo
[root@OEL65 yum.repos.d]#

6. Download necessary RPM file from oracle with command: “wget –no-check-certificate https://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol6 -O /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle”

[root@OEL65 yum.repos.d]# wget –no-check-certificate https://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol6 -O /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
–2015-04-12 18:50:29– https://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol6
Resolving public-yum.oracle.com… 70.186.29.58, 70.186.29.33
Connecting to public-yum.oracle.com|70.186.29.58|:443… connected.
WARNING: no certificate subject alternative name matches
requested host name “public-yum.oracle.com”.
HTTP request sent, awaiting response… 200 OK
Length: 1011 [text/plain]
Saving to: “/etc/pki/rpm-gpg/RPM-GPG-KEY-oracle”

100%[======================================>] 1,011 –.-K/s in 0s

2015-04-12 18:50:30 (16.8 MB/s) – “/etc/pki/rpm-gpg/RPM-GPG-KEY-oracle” saved [1011/1011]

[root@OEL65 yum.repos.d]#

7. Use the following yum command to install the packages from oracle for 12c RDBMS install: “yum install oracle-rdbms-server-12cR1-preinstall”

[root@OEL65 yum.repos.d]# yum install oracle-rdbms-server-12cR1-preinstall
Loaded plugins: rhnplugin, security
This system is receiving updates from ULN.
Setting up Install Process



public_ol6_MySQL | 1.2 kB 00:00
libdmx.x86_64 0:1.1.3-3.el6 libstdc++-devel.x86_64 0:4.4.7-11.el6
xorg-x11-utils.x86_64 0:7.5-6.el6 xorg-x11-xauth.x86_64 1:1.0.2-7.1.el6

Complete!

8. This completes the setup of the VM libraries for Oracle 12c RDBMS.

Larry Catt, OCP

Using explain plan from the SQLPLUS

Oracle provides the ability to examine how a SQL statement will be parsed by oracle with explain plan.

1.  Logon to sqlplus with a user that has DBA privileges.

[oracle@MYLINUX ~]$ sqlplus orcl_admin/*******@ORCL

 

SQL*Plus: Release 11.2.0.3.0 Production on Fri Feb 13:20:51 2014

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

SQL>

 

2.  Create the plan table with the oracle script $ORACLE_HOME/rdbms/admin/utlxplan.sql.  NOTE:  The ‘?’ sign in sqlplus refers to the variable ORACLE_HOME

SQL> @?/rdbms/admin/utlxplan.sql

Table created.

SQL>

 

3.  Now you have the tables created to hold the parsing information, you can execute the explain command.   NOTE: We use the ‘SET’ clause in this example to allow us to easily identify our statement.

SQL> explain plan

2  set statement_id=’TEST1′ for

3  select count(*) from nais.nais_tab;

 

Explained.

 

SQL>

 

4.  Now we can query the table plan_table in our schema.

set pagesize 160

select plan_table_output from table(dbms_xplan.display(‘PLAN_TABLE’,’TEST1′,’TYPICAL’));

 

PLAN_TABLE_OUTPUT

——————————————————————————–

Plan hash value: 1794364880

 

—————————————————————————————————————————-

 

| Id  | Operation                  | Name     | Rows  | Cost (%CPU)| Time     |Pstart| Pstop |    TQ  |IN-OUT| PQ Distrib |

——————————————————————————–

——————————————–

 

|   0 | SELECT STATEMENT           |          |     1 |   334K  (1)| 01:18:02 |      |       |        |      |            |

 

|   1 |  SORT AGGREGATE            |          |     1 |            |          |      |       |        |      |            |

 

|   2 |   PX COORDINATOR           |          |       |            |          |      |       |        |      |            |

 

|   3 |    PX SEND QC (RANDOM)     | :TQ10000 |     1 |            |          |      |       |  Q1,00 | P->S | QC (RAND)  |

 

|   4 |     SORT AGGREGATE         |          |     1 |            |          |      |       |  Q1,00 | PCWP |            |

 

|   5 |      PX PARTITION RANGE ALL|          |   554M|   334K  (1)| 01:18:02 |    1 |   791 |  Q1,00 | PCWC |            |

 

|   6 |       TABLE ACCESS FULL    | TEST_TAB|   554M|   334K  (1)| 01:18:02 |    1 |   791 |  Q1,00 | PCWP |            |

 

—————————————————————————————————————————-

 

 

5.  This completes the use of explain plan for Oracl

Part 5 – Building Oracle 12c development suite – Network setup for Oracle Enterprise Linux 6.5 on Oracle VirtualBox

Network setup for Oracle Enterprise Linux 6.5 on Oracle VirtualBox

Oracle Corporation provides the ability for developers to create a complete development suite on their personal windows desktop or laptop without requiring the expensive equipment required for a true production system. This article outlines the process for configuration network for an Oracle Enterprise Linux 6.5 installation on Oracle VirtualBox in preparation for installation of Oracle 12c RDBMS.
NOTE: This process can be used for most Linux installations, regardless of original company or organization providing the base Linux OS.

1. Logon to your Windows desktop/laptop as an administrator, open a command prompt and execute the command IPCONFIG to gather current IP configuration for your host system.
C:\ >ipconfig
Windows IP Configuration
Ethernet adapter Local Area Connection:
Connection-specific DNS Suffix . : C3CEN.Net
Link-local IPv6 Address . . . . . : fe80::b9b2:d070:d80f:82d1%11
IPv4 Address. . . . . . . . . . . : 10.30.15.90
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 10.30.15.1

Ethernet adapter VirtualBox Host-Only Network:
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::bdca:1b67:c60c:7b1%19
IPv4 Address. . . . . . . . . . . : 10.30.15.127
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 10.30.15.1

C:\ >

NOTE: The following information:
HOST IP 10.30.15.90
Host Subnet 255.255.255.0
Gateway 10.30.15.1
Guest IP 10.30.15.127
Guest Subnet 255.s255.255.0

2. Open Oracle VirtualBox, from the main top menu of VirtualBox and Select File ? Preferences…

3. On the Left panel menu select Network and in the right hand panel Host-only Network.

4. Click the PLUS sign symbol to the right of the right hand panel to create a new Host-adaptor.

5. Once the new Adapter is created highlite it and select the screwdriver edit icon on the right hand side.

6. Select the enter a new IP address for your adapter and network mask under the Adapter tab, do not feel anything out under the DHCP Server tap and press OK and press OK at the original Network configuration screen.

7. On your host machine, open another command prompt and execute the “IPCONFIG” command to see your new adapter does exist.
C:\ >ipconfig
Windows IP Configuration
Ethernet adapter Local Area Connection:
Connection-specific DNS Suffix . : C3CEN.Net
Link-local IPv6 Address . . . . . : fe80::b9b2:d070:d80f:82d1%11
IPv4 Address. . . . . . . . . . . : 10.30.15.93
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 10.30.15.1

Ethernet adapter VirtualBox Host-Only Network:
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::bdca:1b67:c60c:7b1%19
IPv4 Address. . . . . . . . . . . : 10.30.15.127
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 10.30.15.1

Ethernet adapter VirtualBox Host-Only Network #2:
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::c82c:7a2f:242c:fcfb%35
IPv4 Address. . . . . . . . . . . : 192.168.130.1
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . :

C:\ >
8. High light guest OS you created in Part 3 of this serious and select Settings tag from tool bar ? Network from left panel ? check the Enable Network Adapter ? Select Host-only Adapter and ensure the Adapter you just selected is in the Name: field from drop down button then press the OK button.
?

9. High light guest OS you created in Part 3 of this serious and select Settings tag from tool bar ? Network from left panel ? select Adapter 2 Tab ?check the Enable Network Adapter ? Select Internal Network from drop down button and ensure Promiscuous Mode is set to Allow All then press the OK button.
?

10. High light guest OS you created in Part 3 of this serious and select Settings tag from tool bar ? Network from left panel ? select Adapter 3 Tab ?check the Enable Network Adapter ? Select Bridge Adapter from drop down button with the name of the physical device and ensure Promiscuous Mode is set to Allow All then press the OK button.
?
11. Double click on the guest OS you created in Part 3 of this serious in the left hand panel of VirtualBox. In this instruction set the name is OEL_65.

12. Once the Oracle Linux Server prompt appear below logon as the user root with the password used during installation in Part 4 of this serious. NOTE: In this series, we installed a base Linux Server without desktop support. If your installation has desktop support, just open a terminal screen to perform the rest of this procedure.

login as: root
root@10.30.15.127’s password:
Last login: Sat Jan 4 15:24:18 2015
[root@oel65 ~]#

13. Open the file /etc/hosts and add the host IP and hostname you wish to use.

[root@oel65 ~]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.130.1 oel65

14. As the root user navigate to the directory /etc/sysconfig/network-scripts and use VI editor to adjust the file ifcfg-eth0. Ensure that the ONBOOT is set to YES and

[root@oel65 ~]# cd /etc/sysconfig/network-scripts/
[root@oel65 network-scripts]# cat ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
HWADDR=08:00:27:A2:02:20
IPADDR=10.30.15.127
PREFIX=24
GATEWAY=10.30.15.1
DNS1=10.10.15.21
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME=”System eth0″
NETMASK=255.255.255.0
USERCTL=no

[root@oel65 network-scripts]#

15. Restart the network services with command “service network restart”

[root@oel65 network-scripts]# service network restart
Shutting down interface eth0: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: Determining if ip address 10.30.15.127 is already in use for device eth0…
[ OK ]
[root@oel65 network-scripts]#

16. Test your network connection to and from an outside machine with ping command:

17. This completes the setup of the VM network.

Larry Catt, OCP

Part 4 – Building Oracle 12c development suite – Installation of Oracle Enterprise Linux 6.5

Installation of Oracle Enterprise Linux 6.5

Oracle Corporation provides the ability for developers to create a complete development suite on their personal windows desktop or laptop without requiring the expensive equipment required for a true production system. This article outlines the process Installation of Oracle Enterprise Linux 6.5 using your personal desktop/laptop and Oracle VirtualBox.

1. Logon to your Windows desktop/laptop as an administrator and open Oracle VirtualBox.
2. Double click on the guest OS you created in Part 3 of this serious in the left hand panel of VirtualBox. In this instruction set the name is OEL_65.

3. Once the Oracle Linux Server 6.5 Installation screen appears, ensure that ‘Install or Upgrade existing system’ is highlighted and press the return button.

4. The screen will appear asking you to validate your installation media, use the error keys to select Skip button and press the Enter key.

5. At the Welcome screen, select the Next button and press the return key.

6. At the Language screen, select your language preference and press the Next Key.

7. At the keyboard selection screen, select your desired keyboard and press Next button.

8. At the devices installation screen, select Basic Storage Devices and press the Next button.

9. At the Storage Device Warning page, select Yes, discard any data.

10. At the name this computer screen, type in the name of your computer and press the Next button.

11. At the time zone screen select your nearest city and press the Next button.

12. At the root account password page, enter the password you wish to use for root access. NOTE: root access is the primary administrative account on a linux system.

13. If the Weak Password warning appears, either select cancel or use Anyways buttons.

14. At the type of installation page, select Replace Existing Linux System(s) and press the Next button.

15. If a Writing storage configuration to disk warning appears, select the Write changes to disk button.

16. A Default installation page, select Basic Server and all defaults and press the Next button.

17. Now the installation will proceed.
18. At the Congratulations screen, click the Reboot button.

19. This completes the installation of Oracle Enterprise Linux 6.5 on Oracle VirtualBox software.
Larry Catt

Resolving Oracle Error ORA-01653 by removing audit records

ERROR:
ORA-00604: error occurred at recursive SQL level 1
ORA-01653: unable to extend table SYS.AUD$ by 4096 in tablespace SYSTEM
ORA-02002: error while writing to audit trail
ORA-00604: error occurred at recursive SQL level 1
ORA-01653: unable to extend table SYS.AUD$ by 4096 in tablespace SYSTEM

1. Logon to the Oracle database as a sysdba user.

2. Validate that the system tablespace is out of space.

set pagesize 500
select a.tablespace_name,
(select sum(b.bytes)/1024/1024/1024 from dba_data_files b where a.tablespace_name=b.tablespace_name) as GB_TOT,
(select sum(c.bytes)/1024/1024/1024 from dba_free_space c where a.tablespace_name=c.tablespace_name) as GB_AVAIL,
100*(select sum(c.bytes) from dba_free_space c where a.tablespace_name=c.tablespace_name)/(select sum(b.bytes) from dba_data_files b where a.tablespace_name=b.tablespace_name) as PERC_FREE
from dba_tablespaces a where tablespace_name=’SYSTEM’;

TABLESPACE_NAME GB_TOT GB_AVAIL PERC_FREE
—————————— ———- ———- ———-
SYSTEM 19.53125 9.1766357 49.184375

SQL>

3. The query above showes that the system tablespace is out of space. In this article we will purge records from the SYS.AUD$ table to address this error, additionally we
can add additional storage space to address the above error message. This alternative is addressed in another article.

4. Verify that AUD$ tables is indeed consuming a considerable amount of space.

SQL> select sum(bytes)/1024/1024 from dba_segments where SEGMENT_NAME=’AUD$’;

SUM(BYTES)/1024/1024
——————–
9694

SQL>

5. Purge this records with the following statement which remove all records older then 1 day.

SQL> truncate table sys.aud$;

Table truncated.

SQL> commit;

Commit complete.

SQL>

6. Validate that the SYSTEM tablespace has increased.

set pagesize 500
select a.tablespace_name,
(select sum(b.bytes)/1024/1024/1024 from dba_data_files b where a.tablespace_name=b.tablespace_name) as GB_TOT,
(select sum(c.bytes)/1024/1024/1024 from dba_free_space c where a.tablespace_name=c.tablespace_name) as GB_AVAIL,
100*(select sum(c.bytes) from dba_free_space c where a.tablespace_name=c.tablespace_name)/(select sum(b.bytes) from dba_data_files b where a.tablespace_name=b.tablespace_name) as PERC_FREE
from dba_tablespaces a where tablespace_name=’SYSTEM’;
TABLESPACE_NAME GB_TOT GB_AVAIL PERC_FREE
—————————— ———- ———- ———-
SYSTEM 19.53125 19.1766357 98.184375

SQL>

7. This completes resolving Error ORA-01653

Larry Catt

Resolving Oracle Error ORA-01653 by adding additional storage

ERROR:
ORA-00604: error occurred at recursive SQL level 1
ORA-01653: unable to extend table SYS.AUD$ by 4096 in tablespace SYSTEM
ORA-02002: error while writing to audit trail
ORA-00604: error occurred at recursive SQL level 1
ORA-01653: unable to extend table SYS.AUD$ by 4096 in tablespace SYSTEM

1. Logon to the Oracle database as a sysdba user.

2. Validate that the system tablespace is out of space.

set pagesize 500
select a.tablespace_name,
(select sum(b.bytes)/1024/1024/1024 from dba_data_files b where a.tablespace_name=b.tablespace_name) as GB_TOT,
(select sum(c.bytes)/1024/1024/1024 from dba_free_space c where a.tablespace_name=c.tablespace_name) as GB_AVAIL,
100*(select sum(c.bytes) from dba_free_space c where a.tablespace_name=c.tablespace_name)/(select sum(b.bytes) from dba_data_files b where a.tablespace_name=b.tablespace_name) as PERC_FREE
from dba_tablespaces a where tablespace_name=’SYSTEM’;

TABLESPACE_NAME GB_TOT GB_AVAIL PERC_FREE
—————————— ———- ———- ———-
SYSTEM 10.27125 .01766357 .024375

SQL>

3. The query above showes that the system tablespace is out of space. The quickest fix is to add additional space to the SYSTEM tablespace, additionally we
can address the amount of data stored in the AUD$ tables referenced in the above error message. This alternative is address in another article.

4. To add additional space to the system tablespace, find the current location of SYSTEM data files on your system with the following statement.

SQL> select file_name, bytes/1024/1024 from dba_data_files where tablespace_name=’SYSTEM’;

FILE_NAME BYTES/1024/1024
——————————— —————

/u01/oradata/UCOP/SYSTEM01.DBF 10000

SQL>

5. Verify that you have enough space available on your drives and add an additional datafile;

alter tablespace SYSTEM add datafile ‘/u01/oradata/UCOP/SYSTEM02.DBF’ size 10000m;

SQL> alter tablespace SYSTEM add datafile ‘/u01/oradata/UCOP/SYSTEM02.DBF’ size 10000m;

Tablespace altered.

SQL>

6. Validate that you know have available free space in the SYSTEM tablespace and re-execute the statement which caused your initial error.

set pagesize 500
select a.tablespace_name,
(select sum(b.bytes)/1024/1024/1024 from dba_data_files b where a.tablespace_name=b.tablespace_name) as GB_TOT,
(select sum(c.bytes)/1024/1024/1024 from dba_free_space c where a.tablespace_name=c.tablespace_name) as GB_AVAIL,
100*(select sum(c.bytes) from dba_free_space c where a.tablespace_name=c.tablespace_name)/(select sum(b.bytes) from dba_data_files b where a.tablespace_name=b.tablespace_name) as PERC_FREE
from dba_tablespaces a where tablespace_name=’SYSTEM’;

TABLESPACE_NAME GB_TOT GB_AVAIL PERC_FREE
—————————— ———- ———- ———-
SYSTEM 19.53125 9.1766357 49.184375

SQL>

7. This completes resolving Error ORA-01653

Larry Catt

Part 2 – Building Oracle 12c development suite – Installation of Oracle VirtualBox

Installation of Oracle VirtualBox
Oracle Corporation provides the ability for developers to create a complete development suite on their personal windows desktop or laptop without requiring the expensive equipment required for a true production system. This article outlines the process of installing Oracle VirtualBox for installation of guest Operating Systems on your windows desktop or laptop.

NOTE: This suite can be installed on any type of OS, just download the appropriate VirtualBox software package for your base system.
Required files:
VirtualBox-4.3.20-96997-Win.exe
or
The latest version available at www.oracle.com
1. Logon to your windows desktop or laptop as an administrator.
2. Double click on the VirtualBox executable.
3. Click on Next button at the Welcome page.

4. Click on the Next button at the Custom Setup page.

5. Click on the Next button at the Custom Setup Options page.

6. Click on the Next button at the Warning Network Interfaces page.

7. Click on the Install button at the Ready to Install page.

8. After Installation completes, click the Finish button.

9. The administration console will open after installation is completed.

Larry Catt

Part 1 – Building Oracle 12c development suite – Media packages required for installation of Oracle Enterprise Linux 6.5

Media packages required for installation of Oracle Enterprise Linux 6.5
Oracle Corporation provides the ability for developers to create a complete development suite on their personal windows desktop or laptop without requiring the expensive equipment required for a true production system. This article outlines the required packages to download from Oracle Corporation website to deploy a development site on your personal windows based desktop or laptop.

NOTE: This suite can be installed on any type of OS, just download the appropriate VirtualBox software package for your base system.
Required downloads:
VirtualBox-4.3.20-96997-Win.exe
V41362-01 – Oracle Linux Release 6 Update 5 for x86_64 (64 Bit)
1. If you do not already have an Oracle Corporation Developers logon, go to www.oracle.com and create an account.
2. Logon to the oracle website with your developers account and navigate the website to the latest Virtual Box download. As of this writing, the URL was: http://www.oracle.com/technetwork/server-storage/virtualbox/downloads/index.html?ssSourceSiteId=ocomen#vbox
3. Logon to the oracle website with your developers account and navigate the website to the latest Oracle Enterprise Linux download. As of this writing, the URL was: https://edelivery.oracle.com/EPD/Download/get_form?egroup_aru_number=17052719 Select the media package V41362-01 for Oracle Linux 6.5 Release Date: Dec – 10- 2013.
4. This are the two required packages to build an Oracle Linux system on your Windows based desktop or laptop.

Larry Catt

Continue Oracle loop past exception

Oracle provides for handling of error messages in programming blocks through the use of exceptions.    During the execution of a loop, the general exception clause at the end of a procedure, function or pl/sql block will exit the loop for handling of error, thus stopping the processing.    However, you can change this behavior by placing an exception clause within the loop block itself.    This procedure shows how to setup a loop with an exception clause, so the loop is not exited on error.  NOTE:  To just see the loop exception go to step 5.

  1. Create the following test table:

create table test_a(a number);

 

declare

n number:=1;

begin

while n<4

loop

insert into test_a(a) values(n);

n:=n+1;

end loop;

end;

/

 

 

  1. Now execute the following block to extract the data from table test_a

set serveroutput on

declare

n number;

begin

for rec in(select * from test_a)

loop

dbms_output.put_line(rec.a);

end loop;

end;

/

1

2

3

PL/SQL procedure successfully completed.

 

  1. Create an error by Insert the line “if mod(rec.a,2)=0 then n:=rec.a/0 else dbms_output.put_line(rec.a);” after the

 

set serveroutput on

declare

n number;

begin

for rec in(select * from test_a)

loop

if mod(rec.a,2)=0 then n:=rec.a/0; else dbms_output.put_line(rec.a); end if;

end loop;

end;

/

1

declare

*

ERROR at line 1:

ORA-01476: divisor is equal to zero

ORA-06512: at line 6

 

 

SQL>

 

  1. Now insert the exception “exception when others then null;” at the end of the block and we see that the exception is handled by the loop exited before giving us the value of 3.

SQL> set serveroutput on

declare

n number;

begin

for rec in(select * from test_a)

loop

if mod(rec.a,2)=0 then n:=rec.a/0; else dbms_output.put_line(rec.a); end if;

end loop;

exception when others then null;

end;

/

1

 

PL/SQL procedure successfully completed.

 

SQL>

  1. Wrap the internals of the for loop in its own block and move the exception clause inside the block, now you see the exception is handled and the loop continues, giving us the the value of 3.

 

SQL> set serveroutput on

declare

n number;

begin

for rec in(select * from test_a)

loop

begin

if mod(rec.a,2)=0 then n:=rec.a/0; else dbms_output.put_line(rec.a); end if;

exception when others then null;

end;

end loop;

end;

/

1

3

 

PL/SQL procedure successfully completed.

 

SQL>

 

  1. This completes handling of exceptions in a oracle loop which continues.

 

Larry Catt, OCP