Re: Named pipes?
Posted in 1998
On Wed, 9 Sep 1998, Florin Micle wrote:
> Here is my problem:
>
> I want to send data to a C++ program. I would like to know if there is a
> mechanism like named pipe in Oracle (DBMS_PIPE.SendMessage())
> Is there a way to do such things in Informix? Any other possibilities?
> I mention that I have: Informix SE 7.02 (no ESQL/C) and use a GNU
^^^^
7.20?
> compiler with C++ libraries. I'm very new in working in Unix environment, so
> bare with me :-).
What sort of program do you want to use to get the data from the database?
Since you don't have ESQL/C, you are probably planning to use DB-Access.
You can arrange for your C++ program to start DB-Access with the correct
argument list and for it to write SQL statements to the standard input
of DB-Access and to read responses on the standard output of DB-Access.
You'd probably do this with either a pair of pipes (good old-fashioned
anonymous pipes) or a socket (which should provide bi-directional
communications, IIRC) -- I'm old fashioned. You'd have to parse the
output from DB-Access which would not be as easy as you'd like.
Alternatively, you do more or less as Peter suggested and arrange to
UNLOAD data to a file which happens to be a named pipe. You can then
arrange for your C++ program to open the named pipe and read the data.
mkfifo fifo
dbaccess stores7 - <<! &
UNLOAD TO "fifo" SELECT * FROM Customer; !
sleep 30
cat fifo
If you want to get fancier, you are going to need ESQL/C, somewhere
along the line. Your options are then much greater. If you really
want to do things with named pipes, then the SQLCMD program in the
IIUG archives has a mode which handles named pipes for input and
output, or you can write your own program. Or you can embed the
ESQL/C code directly into your C++ program. Or ...
Yours,
Jonathan Leffler (jleffler@informix.com) #include <witticism.h>
Guardian of DBD::Informix v0.60 -- http://www.perl.com/CPAN
Informix IDN for D4GL & Linux -- http://www.informix.com/idn