Re: Prolog and Oracle
Date: Wed, 16 Feb 1994 08:35:50 GMT
Message-ID: <1994Feb16.083550.9376_at_neptune.inf.ethz.ch>
In article <TOM.94Feb14105307_at_heather.kwi.com>, tom_at_heather.kwi.com
(Tom Howland) writes:
|> > we would like to connect Quintus-Prolog with Oracle using TCP/IP.
|> > But we do not know WHAT Prolog have to send the Oracle-Server, e.g.
|> > what kind of data have TERM to be in the Prolog-predicate
|> > tcp_send(Tag,Term) to get an answer from the Oracle-Server.
|> >
|> > Does anyone know if it is possible and how or where we can get the
|> > information ?
|>
|> I wrote library(tcp). I can tell you that you won't want to use
|> tcp_send/2. Rather, you'll want to use
|>
|> tcp_output_stream(+Socket, -Stream)
|>
|> and then operate on the Stream directly. Perhaps sending SQL queries.
|>
|> A better solution might be to buy Quintus's interface to Oracle, which
|> has lots of low-level optimizations.
If all you want to do is send SQL statements for execution to Oracle and process the results, I suggest you should also think about using the OCI (Oracle Call Interface) via the foreign function interface of Quintus/SICStus Prolog rather than sending SQL statements and parsing its replies.
The advantage of the (C-based) OCI interface is that you get results and/or error messages in a "structured" form. Otherwise, you have to parse Oracle's (SQL*Plus?) output and ensure that your program never waits for output when Oracle isn't sending any. I have done something like that using pseudo TTY's and RPC (instead of TCP/IP) for Unify 3.2 back in 1985 and found it to be a pain.) Thanks to SQL*Net, the OCI also works across the net (i.e., if your programs run on a host different from the one where the Oracle database resides).
This is of course not portable to other SQL engines since e.g. Sybase has a different call interface than Oracle ("dblib"). On the other hand, the solution with parsing the output of an SQL interpreter is non-portable too, even if the same "flavor" of SQL is supported by both ... )
-- Robert Marti | Phone: +41 1 632 72 60 Informationssysteme | FAX: +41 1 262 39 73 ETH-Zentrum | E-Mail: marti_at_inf.ethz.ch CH-8092 Zurich, Switzerland |Received on Wed Feb 16 1994 - 09:35:50 CET
