Expert Oracle pp 771-841 | Cite as

C-Based External Procedures


In this chapter, we have covered the main issues surrounding external procedures such as:
  • Maintaining a state using contexts.

  • Using the OS-independent file APIs.

  • Making our external procedure code parameterized using external parameter files.

  • How to instrument our code (using debugf) to allow for ‘debugging from afar’.

  • How to code defensively (always pass the context, always pass the Null indicators, and so on).

  • How to use a generic template to get your external procedures ‘jump started’ quickly, with lots of functionality.

  • The differences between a pure OCI external procedure and one that uses Pro*C.

  • How to map and pass the relevant PL/SQL data types to and from C.

  • How to pass collections of data back and forth as well.

Given the generic template and makefiles above, you have all you need to write an external procedure from start to finish in a couple of minutes now. The tricky part is mapping the datatypes and the tables above, but that is easily accomplished by following the two tables in The Wrapper section - they tell you ‘given this type, you will use that type’. Then, just follow the guidelines I have for passing the parameters in the example above (always send the context, always send the MAXLEN attribute for strings and raws, always send the Null indicator, and so on). If you do that, you’ll be writing external procedures in no time.


Error Message Configuration File Parameter File Generic Template Package Body 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Copyright information

© Thomas Kyte 2005

Personalised recommendations