Link to home
Start Free TrialLog in
Avatar of bobyjose
bobyjose

asked on

Reading a file through Pl./SQL and writing a file through C

In my project design, one pro*c/c++ program opens a file and writes log messages into it. And these message are popup in forms5 as and when it generates.
My approach towards this problem in two ways
1) I created a program to write log messages in a file and another PL/SQL program for reading that file. Problem is I could not do simultaneously both process!But I need to do both simultaneously!How can solve It?
2) I created a C library program which reads file and returns the string. I connected this library through a external procedure with oracle. Even though I could not solve this problem, due to some memory related errors are poping up when I tried to invoke this library. Error generating point in c library is return statement.  
Avatar of jjmcd
jjmcd

Why not do the mainline in ProC instead of PL/SQL.  This would be pretty straightforward, IMO.
Could you explain the architecture of your project -

Where is the logic in your project, that generates the messages which need logging? is it a batch program running in background ?

What causes messages to popup in forms5 ?

Are all you components running on the same machine ?
Avatar of bobyjose

ASKER

Hi,
     I can not use PL/SQL for writing log messages. The files (reading files) are in binary/hex/Oct formats, which are being generated by hardware device ports. So C or proc is using for reading these files. This process may be happening for one week or two weeks with out any break. During this process, c program (reading file) generates some trace/log messages to a file (log file). Up to this, all operations are happening in backend (DEC Unix). In this project, we are using froms50 as front-end (windows), where we are being tried to demo log-messages to user, who wants to know status of backend file reading process (he/she is siting at client m/c). That is why, I forced to use PL/SQL for reading that log file and tried to display on forms50. And also, I have to do both process simultaneously.
Option I: can you have your PRO*C program insert info into a special logging table, which you can view from the Forms5 application using regular selects ?

Option II: I have implemented a generic process (listener) which runs on a unix  or NT server. This is a PRO*C program which listens on a DBMS PIPE. Client applications (like FORMS5), request the PRO*C program to view files on the unix machine. Using a simple protocol, the forms application (which acts like a browser) talks to the PRO*C program and requests for table of contents, and then for  specific pages to view from the textfile on the server. This method of having a listener act as an agent on the server machine to enable clients to view log files of server jobs is used in about 50 sites of my company's customers, running FORMS applications against UNIX / NT servers running the Oracle instance. There is no problem with the fact that the file is being written by one process, and concurrently being read by another. This has been implemented on various plaforms NT4 / SUN / DEC / SGI / HP / AViiON / UniSys / Linux / NCR etc.
The benefits of option II are that you can use C file I/O functions like seeks, binary block reads etc. You can emulate functionality of "tail -f" behaviour on the Forms5 application.
By having the listener process maintain a map (like a table of contents or index) of the file being viewed (while  it is being written).
This will let your Forms5 client, at each refresh, know how many pages exist in the file at the server, and lets you jump to any page (first / last / specific) etc.

If you are interested in this implementation, I can post more information.
Yes, I am interest to know a more about this method. Could u pls send more details with example pgms ? my mails id is bobyjose@india.dharma.com;
Yes, I am interest to know a more about this method. Could u pls send more details with example pgms ? my mails id is bobyjose@india.dharma.com;
ASKER CERTIFIED SOLUTION
Avatar of cadabra
cadabra

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial