Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

How to query SQL database from Prolog and use the queried result as facts?

290 views
Skip to first unread message

Osiris Xu

unread,
Jul 25, 2014, 9:32:17 PM7/25/14
to swi-p...@googlegroups.com

Is it possible to couple Prolog to Relational Databases, SQL for example, and use commands like the following

   ancestor(X, Y) :- SQL('SELECT CHILD, PARENT INTO X, Y
                                    FROM FATHER WHERE CHILD =X').
   ancestor(X, Y) :- father(X, Z), ancestor(Z,Y).


to query SQL database from Prolog and use the queried result as facts?


norbert...@gmail.com

unread,
Jul 26, 2014, 6:08:12 AM7/26/14
to swi-p...@googlegroups.com

Carlo Capelli

unread,
Jul 26, 2014, 9:03:45 AM7/26/14
to Osiris Xu, swi-p...@googlegroups.com
Take a look at library(odbc), here for instance.

Syntax is different than what you show, and of course you need ODBC installed,
OTOH it works with whatever DB has a driver - nearly all.

About your syntax: I think will be difficult you find any compiler for a 'mixed' recursive query - but I could be wrong
Carlo


--
You received this message because you are subscribed to the Google Groups "SWI-Prolog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swi-prolog+...@googlegroups.com.
Visit this group at http://groups.google.com/group/swi-prolog.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages