Deprecated: Assigning the return value of new by reference is deprecated in /home/jjonahha/public_html/oracle-internals/blog/wp-includes/cache.php on line 36

Deprecated: Assigning the return value of new by reference is deprecated in /home/jjonahha/public_html/oracle-internals/blog/wp-includes/query.php on line 21

Deprecated: Assigning the return value of new by reference is deprecated in /home/jjonahha/public_html/oracle-internals/blog/wp-includes/theme.php on line 540
ORACLE INTERNALS » Chewing the CUD: Digesting Generated Compilation Unit Data

Nov 14 2007

Chewing the CUD: Digesting Generated Compilation Unit Data

Published by jonah.harris at 1:50 am under General, Internals, Tools

If you’ve ever played around with the Oracle Embedded SQL precompilers, you may have noticed a nifty little declaration for compilation unit data (CUD). While it’s named a bit differently depending on the host language, sqlcud0 (for Pro*C) or SQLCUD (for Pro*COBOL), its purpose remains the same. So, why am I spending time discussing the CUD? In addition to seeing several requests for further information in online forums, I’ve also received three or four inquiries from people wondering what in the world this CUD thingamajigger represents. After an hour or so of research, I may be able to describe it to you (a bit).Before we dive into the CUD, so to speak, let’s first discuss the architecture of precompilers and the code they generate. A SQL precompiler is a piece of software which compiles the SQL commands stored within a source program into appropriate database API function calls in the source language, such as C, C++, COBOL, FORTRAN, etc. After the precompiler has completed its work, a standard compiler is then used to build a binary executable or library containing the generated database function calls. In the Oracle world, we would look to using Pro*C for embedded SQL in C/C++, Pro*COBOL for COBOL, Pro*FORTRAN for FORTRAN, etc. However, as Oracle provides several client-side database APIs, it’s important to understand the one used by precompiler-generated calls, SQLLIB.

SQLLIB is a specialized library which, like OCI, is based on Oracle’s User Programmatic Interface (UPI). SQLLIB was designed to specifically deal wth the many aspects of handling SQL within a host language. You will find however, that SQLLIB is for the most part, undocumented. I believe there are two reasons for this. First, SQLLIB (like UPI), could change from release to release. As such, Oracle would have to update a lot more documentation, etc. The second reason, which is just my opinion, is that SQLLIB and UPI provide a proprietary interface into Oracle with more options than are presented in OCI.

4 Responses to “Chewing the CUD: Digesting Generated Compilation Unit Data”

  1. sutharsanon 06 Aug 2008 at 10:53 am

    hi Harris,

    i am sutharsan. i am working on a application which is developed in unix and later it is converted to MFC(VC++).

    In this MFC application they are using the CUD(Compilation Unit Data) to interact with oracle. The header files used in this apps are sqlca.h, oraca.h, and the libraries are orasqx10.lib and orasql10.lib.

    My task in this application is i have to retrive and update some more newly added tables in the database. i am having the cud array like this

    static const short sqlcud0[] =
    {10,4130,0,0,0,
    5,0,0,1,0,0,2075,5,0,0,4,4,0,1,0,1,5,0,0,1,5,0,0,1,10,0,0,1,10,0,0,
    36,0,0,2,0,0,2078,14,0,0,0,0,0,1,0,……

    i didnt understand how they developed this array. if u can plz help me to develop a cud array with a small table with four fields in different datatypes…?

    thanx

    regards

    sutharsan

  2. Rob Nellion 17 Nov 2008 at 4:00 pm

    I’m reading your 11/14/07 online article Chewing the CUD: Digesting Generated Compilation Unit Data, and it appears to be missing a significant part of the information you wished to convey. The article never gets around to discussing the CUD. There are only 2 paragraphs. One on pre-compilers and one on SQLLIB. Where’s the info on the CUD?

  3. jonah.harrison 02 Mar 2009 at 1:43 pm

    Rob,

    You are correct. This suffered from a couple things prior-to and after the move to WordPress. Will correct this soon.

    -Jonah

  4. jonah.harrison 02 Mar 2009 at 1:44 pm

    sutharsan,

    I will fix this article. Hopefully, that will give you the information you need. If not, feel free to ask.

    -Jonah

Trackback URI | Comments RSS

Leave a Reply