Re: [eclipse-clp-users] database interface

From: Joachim Schimpf <jschimpf_at_...127...>
Date: Fri, 31 Oct 2008 15:22:32 +1100
Kish Shen wrote:
> Hi Carlo,
> 
> I am posting this to the mailing list again as it may be of more general 
> interest.
> 
> You are right. I should have looked at the dbi code more closely, as I 
> have not looked at it for a while now.
> 
> The way to get tuples on backtracking is to do it like 
> session_retrieve_tuple/4 in dbi.ecl, using a repeat:
> 
> student(Cursor, Age) :-
> 	repeat,
> 	(cursor_next_tuple(Cursor,Age) -> true ; !, fail).

This would be more robust as

student(Cursor, Age) :-
	repeat,
	(cursor_next_tuple(Cursor,TupleAge) -> TupleAge=Age ; !, fail).

otherwise it will not work when called with Age instantiated
(leading to the cut being executed prematurely).


-- Joachim
Received on Fri Oct 31 2008 - 04:36:14 CET

This archive was generated by hypermail 2.3.0 : Thu Feb 22 2024 - 18:13:20 CET