Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Advanced Oracle PL/SQL Developer's Guide (Second Edition) - Second Edition

You're reading from  Advanced Oracle PL/SQL Developer's Guide (Second Edition) - Second Edition

Product type Book
Published in Feb 2016
Publisher
ISBN-13 9781785284809
Pages 428 pages
Edition 2nd Edition
Languages
Author (1):
Saurabh K. Gupta Saurabh K. Gupta
Profile icon Saurabh K. Gupta

Table of Contents (19) Chapters

Advanced Oracle PL/SQL Developer's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Overview of PL/SQL Programming Concepts Oracle 12c SQL and PL/SQL New Features Designing PL/SQL Code Using Collections Using Advanced Interface Methods Virtual Private Database Oracle SecureFiles Tuning the PL/SQL Code Result Cache Analyzing, Profiling, and Tracing PL/SQL Code Safeguarding PL/SQL Code against SQL injection Working with Oracle SQL Developer Index

Executing external C programs from PL/SQL


Let's us walk through an illustration on how to execute an external procedure, written in the C language, in the Oracle Database.

  • Step 1: Creating and compiling the C program.

    The following C program (GetMax.c) finds the maximum of the two number values:

    #include <stdio.h>
    
    /* Define the function returning the max between two numbers */
    int GetMax(int num1, int num2)
    {
       /* local variable declaration */
       int result;
    
       if (num1 > num2)
          result = num1;
       else
          result = num2;
    
       return result;
    }

    Compile the program by using a C compiler.

    sh-4.3# gcc -c GetMax.c
  • Step 2: Generating the DLL and creating the library object in the Oracle Database.

    We will now generate the DLL for the C program:

    sh-4.3# gcc -shared GetMax.c -o GetMax.dll
    • The library location

      The default paths searched by the extproc process for loading the required library are $ORACLE_HOME/bin and $ORACLE_HOME/lib. For testing purposes, we will continue with the defaults....

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}