My company recently installed an Oracle database and I'm trying to get my existing applications---written in both C and Applescript---to talk with it.
Being a complete newbie to Oracle and databases in general, I was wondering if someone could point me in the right direction. What would be the best way for me to talk with Oracle? If I were to start learning anything, should it be Java? SQL?
Also, I built my apps in Xcode and I'm trying to avoid starting over from scratch. Is there a way to keep my existing code and still talk with Oracle?
My company recently installed an Oracle database and
I'm trying to get my existing applications---written
in both C and Applescript---to talk with it.
anything, should it be Java? SQL?
does you app use sql ? In that case the easiest will be to use jdbc to connect to the database. If it's not using sql I am afraid you are out of luck. I am no developer so I might miss something but I sure know about oracle databases.
I started out three years ago, developing an application in Objective-C and Xcode (it wasn't Xcode at that time) that was to talk to our existing Oracle installation. To be able to talk to Oracle, I made a small Java object, that connects via JDBC to the Oracle. All the rest of the code is in Objective-C.
If you want to follow that approach, and want to know more about how I did it, contact me: ivan at myrvold.org
ls_objectname = string(dwo.name) //Â¶ÃÃÃ³ÃÃ»Â³Ã
if dwo.type <> 'text' and dwo.name <> 'datawindow' and row > 0 then
if row = 0 and this.describe(ls_objectname+".band") = "header" and this.describe(ls_objectname + ".text") <> "!" then //ÃÃÂ·Ã±ÂµÃ£Â»Ã·ÃÃÂ¶ÃÃÃ³
ls_curcol = left(ls_objectname,len(ls_objectname) - 2) //ÂµÂ±ÃÂ°ÃÃÂ¶ÃÃÃ³ÃÃ»Â³Ã
if ls_curcol <> is_oldcol then //ÂµÃ£Â»Ã·ÂµÃÃÃÂ²Â»ÃÂ¬ÃÃÂ¶ÃÃÃ³
this.modify(is_objectname + ".color =" + string(rgb(0,0,0)))
this.modify(ls_objectname + ".color =" + string(rgb(255,0,0)))
is_oldcol = ls_curcol //Â±Â£Â´Ã¦ÃÃÂ´ÃÂµÃ£Â»Ã·ÂµÃÃÃÂ¶ÃÃÃ³
is_objectname = ls_objectname
this.setsort(ls_curcol +" A") //ÃÂ·ÃÂ»Â´ÃÂµÃ£Â»Ã·ÂµÂ±ÃÂ»ÃÃÃÃ½ÃÃ²ÃÃ
ib_accend = not ib_accend
if ib_accend then //ÃÃÂ´ÃÃÃÃÃ½ÃÃ²
this.setsort(ls_curcol + " D") //ÃÃ¢Â´ÃÃÃÂ½ÂµÃÃ²
this.setsort(ls_curcol + " A")
If you are not familiar with ORACLE, my own little advice will be to start with downloading and reading Oracle 10g developer's guide(s) which are available from the OTN site. I found those guides really well written: they will provide you with the most knowledgeable introduction to Oracle features.
Further, if you are familiar with Cocoa programming, you may wish to download and read Oracle OCI (aka Oracle call interface) reference manual(s) from the same documentation site. OCI is a set of C functions that allow you to do almost anything on an Oracle database. All those C functions are compatible with the Cocoa Objective C environment, provided you set up quite a number of parameters.
From my own experience, here is a list of what may need to be done to compile a Cocoa program with Oracle OCI functions. (in all lines below replace $<Something> with the full name)
- On your project "customized settings", initialize the header paths to point to ORACLE header directories. There are three directories: $ORACLE_HOME/rdbms/demo, $ORACLE_HOME/rdbms/public, $ORACLE_HOME/plsql/public. Write the full paths (again, expand your $ORACLE_HOME ) separated by spaces.
- Idem with the Library search paths: $ORACLE_HOME/lib $ORACLE_HOME/rdbms/lib
- In the "Other Linker flags" add: -lclntsh
- You may also wish to unset the "Zero link" and the "Prebinding" flags
In a file that call an OCI function, add the three lines
(oci.h includes many other files, that is what you need to declare the above three header paths).
Your program should compile with no errors. You may encounter several warnings related to multiple definitions of SSL functions (it will make no harm as long as you do not use them in your program).
Finally, if you want to run your program (within or outside the XCode environment) you need to initialize a few environment variables, the most important being DYLD_LIBRARY_PATH, to point to both $ORACLE_HOME/lib and $ORACLE_HOME/rdbms/lib. You may also wish to initialize $ORACLE_HOME and $ORACLE_SID.
As you know, DYLD_LIBRARY_PATH is Apple's own definition for the usual UNIX LD_LIBRARY_PATH, which points to shared libraries.
To initialize those variables, I follow Apple's advice on session-wide environment variables: on your $HOME directory, create a .MacOSX ( yes: "dotMacOSX") hidden directory and add an "environment.plist" property file filled with those variables to it. Then restart your session to take the parameters into account. This is enough in a development environment.
I hope this may be useful to you. Good luck and again, read ORACLE documentation first: it is definitively not a waste of time!