[mercury-users] data base interface
fjh at cs.mu.oz.au
Tue Sep 30 00:26:11 AEST 1997
Tomas By, you wrote:
> I'm contemplating a Mercury interface to our GATE system, which for
> these purposes can be seen as a custom (text processing oriented)
> data base.
> To allow for destructive update of the DB I suppose a 'state' type
> is needed, like this:
> :- pred add_item(key,value,db_state,db_state).
> :- mode add_item(in,in,di,uo).
> but access only involves one state:
> :- pred get_item(db_state,key,value).
> :- mode get_item(ui,in,out).
> and 'open' would look something like this:
> :- pred db_open(string,db_state).
> :- mode db_open(in,uo).
> Does this make sense?
Yes, that makes perfect sense.
> Any problems I should know about before taking this further?
`ui' modes are not yet supported, I'm afraid.
(Andrew Bromage has been working a change which
will fix that, but he has not yet finished.)
So for the moment you'll have to use a pair of `di, uo' mode arguments
for `get_item', i.e.
:- pred get_item(key,value,db_state,db_state).
:- mode get_item(in,out,di,uo).
Another issue is that if you want support for transactions and/or exception
handling, then things get a bit more complicated.
> Btw, are there any plans to add a data base to the language as in Prolog?
Not as such. But there are a couple of things in the works.
The general idea is to provide lower-level building blocks which
can be used to implemented data bases and other things as well.
For example, the next release will have a new version of the `store'
module using unique modes, with an efficient implementation.
Also I have a hash table module around somewhere which may go into the
standard library eventually.
Another low-level building block is the C interface, which can be used
to interface to external databases. The people at Mission Critical used
that to implement an ODBC interface; we've been working on cleaning up
the interface and including it in our distribution. We had hoped to
include that in 0.7, but it didn't quite make it. Maybe for 0.8.
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 220.127.116.11 | -- the last words of T. S. Garp.
More information about the users