Native compilation of PL/SQL in Oracle 10G (Express) for Windows (32-bit) using MinGW compiler.
Usually machine code works faster than any kind of P-Code. It should be applicable to Oracle PL/SQL code as well. By default PL/SQL is stored as P-Code in a database and is executed by interpreter. However, since Oracle 9i Oracle can execute natively compiled code. It means Oracle (9i and 10g) can translate P-Code into C language, after that it can use C compiler and linker to produce DLLs (one DLL per PL/SQL unit). Oracle 11g can compile native code directly without any 3-rd party compiler.
Oracle 9i for Windows required MS Visual C compiler. Oracle 10g supports MinGW GCC as well.
Although Oracle Express 11G is available, in many places people still use 10G Express.
For training exercise let us setup native compilation using MinGW on 10G Express (10.2.0.1).
1. Check current PL/SQL compilation status
a. select * from v$parameter where name like 'plsql_native_library_dir';
b. select name,type,plsql_code_type FROM dba_plsql_object_settings where owner='SYS';
c. select * from ncomp_dll$;
2. Install MinGW (from www.mingw.org)
3. Configure Oracle according to Ref 1.
The free unpatched Oracle XE 10G has some bugs in spnc_commands file and in the documentation. To make it work with MinGW modify $(ORACLE_HOME)/plsql/spnc_commands, comment all default commands and add following two commands (one line per command):
C:/MinGW/bin/gcc -c %(src) -O1 -I$(ORACLE_HOME)/rdbms/public -I$(ORACLE_HOME)/plsql/include -I$(ORACLE_HOME)/OCI/include -o %(obj)
C:/MinGW/bin/ld -shared -e 0x0 %(obj) -L. -Lc:/MinGW/lib C:/Windows/System32/crtdll.dll $(ORACLE_HOME)/lib/orapls10.lib -o %(dll)
a. I would also recommend to wrap gcc and ld into scripts that would allow to spool compilation details, errors and results into a log file.
i. Wrapper for gcc. C:\oraclexe\app\oracle\product\10.2.0\server\plsql\bin\gcc_wrapper.cmd
set LOG=C:\oraclexe\oradata\XE\nativelib\compile.log
date /T >>%LOG%
time /T >>%LOG%
echo c:/MinGW/bin/gcc %* >>%LOG% 2>&1
c:/MinGW/bin/gcc %* >>%LOG% 2>&1
set R=%errorlevel%
echo errorlevel=%R% >>%LOG% 2>&1
exit /b %R%
ii. Wrapper for ld. C:\oraclexe\app\oracle\product\10.2.0\server\plsql\bin\ld_wrapper.cmd
set LOG=C:\oraclexe\oradata\XE\nativelib\compile.log
echo c:/MinGW/bin/ld %* >>%LOG% 2>&1
c:/MinGW/bin/ld %* >>%LOG% 2>&1
set R=%errorlevel%
echo errorlevel=%R% >>%LOG% 2>&1
exit /b %R%
iii. In this case modify your spnc_commands following way:
C:/oraclexe/app/oracle/product/10.2.0/server/plsql/bin/gcc_wrapper.cmd -c %(src) -O1 -I$(ORACLE_HOME)/rdbms/public -I$(ORACLE_HOME)/plsql/include -I$(ORACLE_HOME)/OCI/include -o %(obj)
C:/oraclexe/app/oracle/product/10.2.0/server/plsql/bin/ld_wrapper.cmd -shared -e 0x0 %(obj) -L. -Lc:/MinGW/lib C:/Windows/System32/crtdll.dll $(ORACLE_HOME)/lib/orapls10.lib -o %(dll)
4. Create directory for DLLs C:\oraclexe\oradata\XE\nativelib
5. Reconfigure Oracle. Run sqlplus / as sysdba
shutdown immediate
startup upgrade
alter system set plsql_native_library_dir= 'C:\oraclexe\oradata\XE\nativelib' scope=both;
alter system set plsql_native_library_subdir_count=0 scope=both;
alter system set plsql_optimize_level=2 scope=both;
alter system set plsql_code_type = NATIVE scope=both;
@?/rdbms/admin/utlrp.sql
@?/rdbms/admin/dbmsupgnv.sql
shutdown immediate
startup
@?/rdbms/admin/utlrp.sql
@?/rdbms/admin/utlrp.sql
@?/rdbms/admin/utlrp.sql
@?/rdbms/admin/utlrp.sql
@?/rdbms/admin/utlrp.sql
-- run utlrp until it returns 0 ERRORS DURING RECOMPILATION
6. Check new PL/SQL compilation status
select name,type,plsql_code_type
from dba_plsql_object_settings where owner='SYS';
select * from ncomp_dll$;
References:
Ref 1: Oracle® Database Installation Guide. 10g Release 2 (10.2) for Microsoft Windows (32-Bit). Part Number B14316-04
4.3.16 Configuring GNU Compiler Collection as the Primary Compiler
http://docs.oracle.com/cd/B19306_01/install.102/b14316/postcfg.htm
Ref 2: Oracle® Database PL/SQL User's Guide and Reference. 10g Release 2 (10.2). Part Number B14261-01
http://docs.oracle.com/cd/B19306_01/appdev.102/b14261/toc.htm
9 Comments:
Very informative article sir! My name is Rida Hashmi, I am a Wordpress developer & work at a Web Development Company which provides Web development & Seo Services In Faisalabad and other cities of Pakistan as well as other Countries. I have to face these types of problems usually during the compilation of SQL and Your blog has helped me somehow. Well, thanks!
Hello, I am Ariba Khan an SEO Expert from Karachi. Very interesting Article. Nowadays I am running a blog for the students.Facing difficulty where we learn SEO in a right way so, Our
SEO Guide for Beginners helps you a lot.
The pinnacle of luxurious warmth for the cold season, the Shearling Jacket Women takes outerwear to new highs courtesy of its chic design
Nice post, also have a look at Color Matching Sterling VA
I am big fan of your blog post
pakistani jewellery online If you are looking to purchase Pakistani jewellery sets online, there are many reputable online retailers that offer a wide selection of beautiful and authentic pieces. Here are a few popular options:
Khazana Jewellery: Khazana Jewellery is a Pakistani jewellery brand that offers a wide range of jewellery sets, including necklaces, earrings, and bracelets. They have an online store that allows you to browse and purchase their products from anywhere in the world.
Sana Safinaz: Sana Safinaz is a popular Pakistani fashion brand that also offers a range of jewellery sets. Their online store features a variety of designs, from traditional kundan sets to more modern and minimalist pieces.
Nazar Brothers: Nazar Brothers is a well-known Pakistani jewellery brand that has been in the business for over 70 years. They have an online store that offers a wide range of jewellery sets, including bridal sets and statement pieces.
Areezay Gold: Areezay Gold is a Pakistani jewellery brand that offers a range of traditional and contemporary jewellery sets. Their online store features a variety of designs, from delicate and understated to bold and eye-catching.
Khaadi: Khaadi is a popular Pakistani clothing brand that also offers a range of jewellery sets. Their online store features a variety of designs, from elegant and traditional to modern and trendy.
When purchasing Pakistani jewellery sets online, it's important to make sure you are buying from a reputable retailer to ensure the authenticity and quality of the products. It's also a good idea to read reviews from other customers to get an idea of the retailer's reputation and the quality of their products jewellery set
pakistani jewellery online Pakistani bangles are a popular form of jewelry in Pakistan that are known for their intricate designs and vibrant colors. These bangles are traditionally made of metal, glass, or plastic and are often adorned with precious or semi-precious stones. Riwayat Jewelry is a well-known brand that specializes in creating high-quality Pakistani bangles. Their collection features a variety of styles, from traditional to modern, and incorporates a range of materials and techniques to create unique and beautiful pieces. Whether worn for everyday use or special occasions, Pakistani bangles from Riwayat Jewelry are a timeless and treasured addition to any jewelry collection jewellery set
If you're putting up a new workstation or upgrading an old one, Lunar Furniture offers sturdy, stylish office chairs in Pakistan that are built to survive spending a lot of time at the desk and have the best ergonomic features.
new hindi song nice artical good efford bro
Post a Comment
<< Home