| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| Hi i have the following problem in SWI-Prolog. I have a Java Class (NodeFieldVal) that is retrieving Information from a backend system. When my predicate nodeFieldVal is first used, Class is not assigned and the first rule matches, therefore a class will be instantiated. Then the second rule matches and actually calls the method to retrieve data. ?- nodeFieldVal(_, 'SCARR.CARRID', _, X). X = 'AA' ; false. When I issue the above query i would suspect that X should be unificated with all possible CARRIDs in SCARR (there are like 35). Instead I only receive one. (The session handling is done inside the Java class). After I traced the execution, I stumbeld upon the reason: After the first result has been found, Class is free again, thus jpl_is_object(Class) fails which ends the backtracking process. The QUESTION is: Is it possible to unificate Class so that it will be bound for more than one recursion step, thus retrieving all values from SCARR? Best regards Daniel CODE: :- use_module(library(jpl)). prepareParams(Field, Row, Content, [Field, Row, Content]) :- nonvar(Row), nonvar(Content). prepareParams(Field, Row, Content, [Field, 0, Content]) :- var(Row), nonvar(Content). prepareParams(Field, Row, Content, [Field, Row, @(null)]) :- nonvar(Row), var(Content). prepareParams(Field, Row, Content, [Field, 0, @(null)]) :- var(Row), var(Content). nodeFieldVal(Class, Field, Row, Content) :- not(jpl_is_object(Class)), jpl_new( nodeFieldValConnector.NodeFieldVal', [], Class), nodeFieldVal(Class, Field, Row, Content). nodeFieldVal(Class, Field, Row, Content) :- jpl_is_object(Class), prepareParams(Field, Row, Content, Params), jpl_call( Class, nodeFieldVal, Params, Return), jpl_get(Return, 'content', Content), jpl_get(Return, 'row', Row). |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.