Home » Developer & Programmer » Precompilers, OCI & OCCI » OCI and Threaded applications (Solaris 10, Oracle 10g)
OCI and Threaded applications [message #589132] Tue, 02 July 2013 09:57 Go to next message
clancypc
Messages: 33
Registered: December 2006
Member
Does anyone out there have any experience of writing a threaded OCI application?

I am writing an application to load data into a database. The general idea is:

Have a parent process that sets up the environment handle, error handle, server handle etc.. Then it will go to a directory and monitor it for any arriving files to be loaded. When it detects a file it creates a child thread to process the file.

The child thread will then create the statement handle and bind handles, process all the data in the file and load it into the database.

My initial thoughts were to create the threads using POSIX threads, but I have noticed in the OCI Programmers Guide that there are OCI thread functions. Does anyone know if I should be using these instead of the POSIX functions or in addition to the POSIX functions?
Thanks
Re: OCI and Threaded applications [message #589151 is a reply to message #589132] Tue, 02 July 2013 16:05 Go to previous messageGo to next message
John Watson
Messages: 4382
Registered: January 2010
Location: Global Village
Senior Member
It sounds to me as though you are trying to write an application which has already been written. You can use the Scheduler to launch a job to read the file into tables automatically whenever a file arrives,

http://docs.oracle.com/cd/E16655_01/server.121/e17636/schedover.htm#CHDHBAFC

Re: OCI and Threaded applications [message #589184 is a reply to message #589151] Wed, 03 July 2013 03:56 Go to previous messageGo to next message
clancypc
Messages: 33
Registered: December 2006
Member
That looks potentially useful, although it takes all the fun out of learning how to write a threaded program Smile . Is the scheduler in 10g? That link is pointing me to an Oracle 12c admin guide.
Re: OCI and Threaded applications [message #589187 is a reply to message #589184] Wed, 03 July 2013 04:05 Go to previous messageGo to next message
John Watson
Messages: 4382
Registered: January 2010
Location: Global Village
Senior Member
Oh, sorry - I missed the fact that you are on 10g, so I assumed the current release. Release 10.2.x has the Scheduler, with event based jobs. But (if I remember correctly) it does not have a pre-configured file watcher, so you have to write your own. Several people have done this, Google around and you may (start hoping!) find an example.
Re: OCI and Threaded applications [message #589213 is a reply to message #589187] Wed, 03 July 2013 06:11 Go to previous message
clancypc
Messages: 33
Registered: December 2006
Member
I have the basic program complete. It can monitor the incoming file directory and load a single file at a time using OCIBindArrayOfStruct function. The next stage is to make it multi threaded so I can load multiple files at a time. My original plan was to use POSIX threads, that was until I saw the section on threads in the OCI Programmers Guide which has made me pause. I am not sure how these funtions interact with the POSIX functions, if they interact at all or if they are mutually exclusive?
I will continue studying the OCI guide, maybe it will become clear to me.
Previous Topic: analytic functions in Pro*C - rank()
Next Topic: Ora-01002 by select for update in SQL statement
Goto Forum:
  


Current Time: Fri Jul 25 08:04:02 CDT 2014

Total time taken to generate the page: 0.14895 seconds