2005-12-19 13:41:15 +00:00
|
|
|
/*************************************************************************
|
|
|
|
* *
|
2015-02-14 11:35:07 +00:00
|
|
|
* YAP Prolog *
|
2005-12-19 13:41:15 +00:00
|
|
|
* *
|
2015-02-14 11:35:07 +00:00
|
|
|
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
2005-12-19 13:41:15 +00:00
|
|
|
* *
|
|
|
|
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
|
|
|
* *
|
|
|
|
**************************************************************************
|
|
|
|
* *
|
|
|
|
* File: myddas_assert_predicates.yap *
|
|
|
|
* Last rev: *
|
|
|
|
* mods: *
|
|
|
|
* comments: Predicates that assert other for the MyDDAS Interface *
|
|
|
|
* *
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
:- module(myddas_assert_predicates,[
|
2006-02-10 23:42:19 +00:00
|
|
|
db_import/2,
|
2005-12-19 13:41:15 +00:00
|
|
|
db_import/3,
|
2006-02-10 23:42:19 +00:00
|
|
|
db_view/2,
|
2005-12-19 13:41:15 +00:00
|
|
|
db_view/3,
|
2006-03-03 14:14:54 +00:00
|
|
|
db_insert/2,
|
2006-01-17 22:54:02 +00:00
|
|
|
db_insert/3,
|
2006-02-10 23:42:19 +00:00
|
|
|
db_abolish/2,
|
|
|
|
db_listing/0,
|
|
|
|
db_listing/1
|
2005-12-19 13:41:15 +00:00
|
|
|
]).
|
|
|
|
|
|
|
|
|
|
|
|
:- use_module(myddas,[
|
|
|
|
db_module/1
|
|
|
|
]).
|
|
|
|
|
|
|
|
:- use_module(myddas_errors,[
|
|
|
|
'$error_checks'/1
|
|
|
|
]).
|
|
|
|
|
|
|
|
:- use_module(myddas_util_predicates,[
|
|
|
|
'$get_values_for_insert'/3,
|
|
|
|
'$make_atom'/2,
|
|
|
|
'$write_or_not'/1,
|
|
|
|
'$copy_term_nv'/4,
|
|
|
|
'$assert_attribute_information'/4,
|
|
|
|
'$make_a_list'/2,
|
|
|
|
'$where_exists'/2,
|
|
|
|
'$build_query'/5
|
|
|
|
]).
|
|
|
|
|
|
|
|
:- use_module(myddas_prolog2sql,[
|
|
|
|
translate/3,
|
|
|
|
queries_atom/2
|
|
|
|
]).
|
|
|
|
:- use_module(myddas_mysql,[
|
|
|
|
db_my_result_set/1
|
|
|
|
]).
|
|
|
|
|
2015-02-14 11:35:07 +00:00
|
|
|
:- use_module(myddas_sqlite3,[
|
2016-07-31 16:02:06 +01:00
|
|
|
sqlite3_result_set/1,
|
|
|
|
c_sqlite3_change_database/2,
|
|
|
|
c_sqlite3_connect/4,
|
|
|
|
c_sqlite3_disconnect/1,
|
|
|
|
c_sqlite3_get_attributes_types/3,
|
|
|
|
c_sqlite3_get_database/2,
|
|
|
|
c_sqlite3_get_fields_properties/3,
|
|
|
|
c_sqlite3_get_next_result_set/3,
|
|
|
|
c_sqlite3_query/5,
|
|
|
|
c_sqlite3_number_of_fields/3,
|
|
|
|
c_sqlite3_row/3
|
|
|
|
]).
|
|
|
|
:- use_module(myddas_odbc,[
|
|
|
|
odbc_result_set/1,
|
|
|
|
c_odbc_change_database/2,
|
|
|
|
c_odbc_connect/4,
|
|
|
|
c_odbc_disconnect/1,
|
|
|
|
c_odbc_get_attributes_types/3,
|
|
|
|
c_odbc_get_database/2,
|
|
|
|
c_odbc_get_fields_properties/3,
|
|
|
|
c_odbc_get_next_result_set/3,
|
|
|
|
c_odbc_query/5,
|
|
|
|
c_odbc_number_of_fields/3,
|
|
|
|
c_odbc_row/3
|
2015-02-14 11:35:07 +00:00
|
|
|
]).
|
|
|
|
|
2016-07-31 16:02:06 +01:00
|
|
|
:- meta_predicate db_import(+,+,:), db_import(+,:).
|
2015-02-14 11:35:07 +00:00
|
|
|
|
2005-12-19 13:41:15 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
% db_import/3
|
2006-02-10 23:42:19 +00:00
|
|
|
% db_import/2
|
2005-12-19 13:41:15 +00:00
|
|
|
%
|
2006-02-10 23:42:19 +00:00
|
|
|
db_import(RelationName,PredName):-
|
2006-03-03 14:14:54 +00:00
|
|
|
db_import(myddas,RelationName,PredName).
|
2016-07-31 16:02:06 +01:00
|
|
|
db_import(Connection,RelationName,PredName0) :-
|
|
|
|
'$error_checks'(db_import(Connection,RelationName,PredName0)),
|
2015-02-14 11:35:07 +00:00
|
|
|
get_value(Connection,Con),
|
|
|
|
table_arity( Con, ConType, RelationName, Arity ),
|
2016-07-31 16:02:06 +01:00
|
|
|
strip_module(PredName0, Module, PredName),
|
2005-12-19 13:41:15 +00:00
|
|
|
not c_db_check_if_exists_pred(PredName,Arity,Module),
|
|
|
|
|
|
|
|
R=..[relation,PredName,Arity,RelationName],
|
|
|
|
% assert relation fact
|
|
|
|
assert(myddas_prolog2sql:R),
|
|
|
|
|
|
|
|
Size is 2*Arity,
|
2015-02-14 11:35:07 +00:00
|
|
|
length(TypesList, Size),
|
2005-12-19 13:41:15 +00:00
|
|
|
% get attributes types in TypesList [field0,type0,field1,type1...]
|
2015-02-14 11:35:07 +00:00
|
|
|
table_attributes( ConType, Con, RelationName, TypesList ),
|
2005-12-19 13:41:15 +00:00
|
|
|
|
2015-02-14 11:35:07 +00:00
|
|
|
% assert attributes facts
|
2005-12-19 13:41:15 +00:00
|
|
|
'$assert_attribute_information'(0,Arity,RelationName,TypesList),
|
|
|
|
|
|
|
|
% build PredName functor
|
|
|
|
functor(P,PredName,Arity),
|
2006-04-30 11:11:25 +01:00
|
|
|
P=..[PredName|LA],
|
2005-12-19 13:41:15 +00:00
|
|
|
|
2006-01-08 16:30:00 +00:00
|
|
|
M=myddas_assert_predicates,
|
2005-12-19 13:41:15 +00:00
|
|
|
%build PredName clause
|
2015-02-14 11:35:07 +00:00
|
|
|
table_access_predicate( ConType, Con, Arity, P, LA, M, Assert ),
|
2005-12-19 13:41:15 +00:00
|
|
|
assert(Module:Assert),
|
|
|
|
c_db_add_preds(PredName,Arity,Module,Con).
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
% db_view/3
|
2006-02-10 23:42:19 +00:00
|
|
|
% db_view/2
|
2005-12-19 13:41:15 +00:00
|
|
|
%
|
2006-02-10 23:42:19 +00:00
|
|
|
db_view(PredName,DbGoal) :-
|
|
|
|
db_view(myddas,PredName,DbGoal).
|
2005-12-19 13:41:15 +00:00
|
|
|
db_view(Connection,PredName,DbGoal) :-
|
|
|
|
'$error_checks'(db_view(Connection,PredName,DbGoal)),
|
|
|
|
get_value(Connection,Con),
|
|
|
|
|
|
|
|
% get arity of projection term
|
|
|
|
functor(PredName,ViewName,Arity),
|
|
|
|
db_module(Module),
|
2006-03-09 15:52:06 +00:00
|
|
|
not c_db_check_if_exists_pred(ViewName,Arity,Module),
|
2005-12-19 13:41:15 +00:00
|
|
|
|
|
|
|
% This copy_term is done to prevent the unification
|
|
|
|
% with top-level variables A='var('A')' error
|
|
|
|
copy_term((PredName,DbGoal),(CopyView,CopyGoal)),
|
|
|
|
|
2006-04-30 11:11:25 +01:00
|
|
|
CopyView=..[ViewName|LA],
|
2005-12-19 13:41:15 +00:00
|
|
|
|
2006-01-08 16:30:00 +00:00
|
|
|
M=myddas_assert_predicates,
|
2005-12-19 13:41:15 +00:00
|
|
|
c_db_connection_type(Con,ConType),
|
2006-01-08 16:30:00 +00:00
|
|
|
|
2005-12-19 13:41:15 +00:00
|
|
|
% build view clause
|
2015-02-14 11:35:07 +00:00
|
|
|
table_view( ConType, Con, CopyView, CopyGoal, Arity, LA, M, Assert ),
|
2005-12-19 13:41:15 +00:00
|
|
|
assert(Module:Assert),
|
|
|
|
c_db_add_preds(ViewName,Arity,Module,Con).
|
|
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
% db_insert/3
|
|
|
|
%
|
|
|
|
%
|
2006-03-03 14:14:54 +00:00
|
|
|
db_insert(RelationName,PredName) :-
|
|
|
|
db_insert(myddas,RelationName,PredName).
|
2005-12-19 13:41:15 +00:00
|
|
|
db_insert(Connection,RelationName,PredName) :-
|
|
|
|
'$error_checks'(db_insert3(Connection,RelationName,PredName)),
|
|
|
|
get_value(Connection,Con),
|
|
|
|
c_db_connection_type(Con,ConType),
|
|
|
|
|
|
|
|
% get relation arity
|
2015-02-14 11:35:07 +00:00
|
|
|
table_arity( Con, ConType, RelationName, Arity ),
|
2005-12-19 13:41:15 +00:00
|
|
|
db_module(Module),
|
|
|
|
not c_db_check_if_exists_pred(PredName,Arity,Module),
|
|
|
|
|
|
|
|
R=..[relation,PredName,Arity,RelationName],
|
|
|
|
% assert relation fact
|
|
|
|
assert(myddas_prolog2sql:R),
|
|
|
|
|
|
|
|
% build PredName functor
|
|
|
|
functor(Predicate,PredName,Arity),
|
2006-04-30 11:11:25 +01:00
|
|
|
Predicate=..[PredName|LA],
|
|
|
|
|
2005-12-19 13:41:15 +00:00
|
|
|
Size is 2*Arity,
|
|
|
|
'$make_a_list'(Size,TypesList),
|
|
|
|
|
|
|
|
% get attributes types in TypesList [field0,type0,field1,type1...]
|
|
|
|
% and build PredName clause
|
2015-02-14 11:35:07 +00:00
|
|
|
table_insert( ConType, Con, RelationName, TypesList, Predicate, LA, Assert ),
|
2005-12-19 13:41:15 +00:00
|
|
|
assert(Module:Assert),
|
|
|
|
c_db_add_preds(PredName,Arity,Module,Con).
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2006-01-17 22:54:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
% db_abolish(+,+)
|
|
|
|
%
|
|
|
|
%
|
|
|
|
db_abolish(Module:PredName,Arity):-!,
|
2006-02-10 23:42:19 +00:00
|
|
|
'$error_checks'(db_abolish(Module:PredName,Arity)),
|
|
|
|
c_db_delete_predicate(Module,PredName,Arity),
|
|
|
|
abolish(Module:PredName,Arity).
|
|
|
|
db_abolish(PredName,Arity):-
|
|
|
|
'$error_checks'(db_abolish(PredName,Arity)),
|
|
|
|
db_module(Module),
|
|
|
|
c_db_delete_predicate(Module,PredName,Arity),
|
|
|
|
abolish(Module:PredName,Arity).
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
% db_abolish(+,+)
|
|
|
|
%
|
|
|
|
%
|
|
|
|
db_abolish(Module:PredName,Arity):-!,
|
|
|
|
'$error_checks'(db_abolish(Module:PredName,Arity)),
|
2006-01-17 22:54:02 +00:00
|
|
|
c_db_delete_predicate(Module,PredName,Arity),
|
|
|
|
abolish(Module:PredName,Arity).
|
|
|
|
db_abolish(PredName,Arity):-
|
2006-02-10 23:42:19 +00:00
|
|
|
'$error_checks'(db_abolish(PredName,Arity)),
|
2006-01-17 22:54:02 +00:00
|
|
|
db_module(Module),
|
|
|
|
c_db_delete_predicate(Module,PredName,Arity),
|
|
|
|
abolish(Module:PredName,Arity).
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
2006-02-10 23:42:19 +00:00
|
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
% db_listing.
|
|
|
|
%
|
|
|
|
%
|
|
|
|
db_listing:-
|
|
|
|
c_db_connection(Con),
|
|
|
|
c_db_preds_conn(Con,Module,Name,Arity),
|
|
|
|
listing(Module:Name/Arity),
|
|
|
|
fail.
|
|
|
|
db_listing.
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
% db_listing.
|
|
|
|
%
|
|
|
|
%
|
|
|
|
db_listing(Module:Name/Arity):-!,
|
|
|
|
c_db_connection(Con),
|
|
|
|
c_db_preds_conn(Con,Module,Name,Arity),
|
|
|
|
listing(Module:Name/Arity).
|
|
|
|
db_listing(Name/Arity):-!,
|
|
|
|
c_db_connection(Con),
|
|
|
|
c_db_preds_conn(Con,Module,Name,Arity),
|
|
|
|
listing(Module:Name/Arity).
|
|
|
|
db_listing(Name):-
|
|
|
|
c_db_connection(Con),
|
|
|
|
c_db_preds_conn(Con,Module,Name,Arity),
|
|
|
|
listing(Module:Name/Arity).
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
2015-02-14 11:35:07 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
% table_arity :- number of columns in a relation.
|
|
|
|
%
|
|
|
|
table_arity( Con, ConType, RelationName, Arity ) :-
|
|
|
|
c_db_connection_type(Con,ConType),
|
|
|
|
writeln( ConType ),
|
|
|
|
% get relation arity
|
|
|
|
( ConType == mysql ->
|
|
|
|
c_db_my_number_of_fields(RelationName,Con,Arity)
|
|
|
|
;
|
2015-02-16 11:44:37 +00:00
|
|
|
ConType == postgres ->
|
|
|
|
c_postgres_number_of_fields(RelationName,Con,Arity)
|
2015-02-14 11:35:07 +00:00
|
|
|
;
|
2015-02-16 11:44:37 +00:00
|
|
|
ConType == odbc ->
|
2016-07-31 16:02:06 +01:00
|
|
|
c_odbc_number_of_fields(RelationName,Con,Arity)
|
2015-02-16 11:44:37 +00:00
|
|
|
;
|
2015-02-14 11:35:07 +00:00
|
|
|
c_sqlite3_number_of_fields(RelationName,Con,Arity))
|
|
|
|
.
|
|
|
|
|
|
|
|
% major attributes types.
|
|
|
|
table_attributes( mysql, Con, RelationName, TypesList ) :-
|
|
|
|
c_db_my_get_attributes_types(RelationName,Con,TypesList).
|
|
|
|
|
2015-02-16 11:44:37 +00:00
|
|
|
table_attributes( postgres, Con, RelationName, TypesList ) :-
|
|
|
|
c_postgres_get_attributes_types(RelationName,Con,TypesList).
|
|
|
|
|
2015-02-14 11:35:07 +00:00
|
|
|
table_attributes( odbc, Con, RelationName, TypesList ) :-
|
2016-07-31 16:02:06 +01:00
|
|
|
c_odbc_get_attributes_types(RelationName,Con,TypesList).
|
2015-02-14 11:35:07 +00:00
|
|
|
|
|
|
|
table_attributes( sqlite3, Con, RelationName, TypesList ) :-
|
|
|
|
c_sqlite3_get_attributes_types(RelationName,Con,TypesList).
|
|
|
|
|
|
|
|
% predicate for DB-> query
|
|
|
|
|
|
|
|
table_access_predicate( mysql, Con, Arity, P, LA, M,
|
|
|
|
( P :- M:('$copy_term_nv'(P,[],G,_),
|
|
|
|
translate(G,G,Code),
|
|
|
|
queries_atom(Code,FinalSQL),
|
|
|
|
db_my_result_set(Mode),
|
|
|
|
'$write_or_not'(FinalSQL),
|
|
|
|
c_db_my_query(FinalSQL,ResultSet,Con,Mode,_),
|
|
|
|
!,
|
|
|
|
c_db_my_row(ResultSet,Arity,LA) ))).
|
|
|
|
|
2015-02-16 11:44:37 +00:00
|
|
|
table_access_predicate( postgres, Con, Arity, P, LA, M,
|
|
|
|
( P :- M:('$copy_term_nv'(P,[],G,_),
|
|
|
|
translate(G,G,Code),
|
|
|
|
queries_atom(Code,FinalSQL),
|
|
|
|
db_my_result_set(Mode),
|
|
|
|
'$write_or_not'(FinalSQL),
|
|
|
|
c_postgres_query(FinalSQL,ResultSet,Con,Mode,_),
|
|
|
|
!,
|
|
|
|
c_postgsres_row(ResultSet,Arity,LA) ))).
|
|
|
|
|
2015-02-14 11:35:07 +00:00
|
|
|
table_access_predicate( sqlite3, Con, Arity, P, LA, M,
|
|
|
|
( P :- M:('$copy_term_nv'(P,[],G,_),
|
|
|
|
translate(G,G,Code),
|
|
|
|
queries_atom(Code,FinalSQL),
|
|
|
|
sqlite3_result_set(Mode),
|
|
|
|
'$write_or_not'(FinalSQL),
|
|
|
|
c_sqlite3_query(FinalSQL,ResultSet,Con,Mode,_),
|
|
|
|
!,
|
|
|
|
c_sqlite3_row(ResultSet,Arity,LA)
|
|
|
|
) )).
|
|
|
|
|
|
|
|
table_access_predicate( odbc, Con, Arity, P, LA, M,
|
|
|
|
( P :- M:('$copy_term_nv'(P,[],G,_),
|
|
|
|
translate(G,G,Code),
|
|
|
|
queries_atom(Code,FinalSQL),
|
2016-07-31 16:02:06 +01:00
|
|
|
c_odbc_result_set(Mode),
|
2015-02-14 11:35:07 +00:00
|
|
|
'$write_or_not'(FinalSQL),
|
2016-07-31 16:02:06 +01:00
|
|
|
c_odbc_query(FinalSQL,ResultSet,Con,Mode,_),
|
2015-02-14 11:35:07 +00:00
|
|
|
!,
|
2016-07-31 16:02:06 +01:00
|
|
|
c_odbc_row(ResultSet,Arity,LA)
|
2015-02-14 11:35:07 +00:00
|
|
|
) )).
|
|
|
|
|
|
|
|
table_insert( mysql, Con, RelationName, TypesList, Predicate, LA,
|
|
|
|
( Predicate :- myddas_assert_predicates:
|
|
|
|
( '$get_values_for_insert'(TypesList,LA,ValuesList),
|
|
|
|
'$make_atom'(['INSERT INTO `',RelationName,'` VALUES ('|ValuesList],SQL),
|
|
|
|
db_my_result_set(Mode),
|
|
|
|
'$write_or_not'(SQL),
|
|
|
|
c_db_my_query(SQL,_,Con,Mode,_)))
|
|
|
|
).
|
|
|
|
|
2015-02-16 11:44:37 +00:00
|
|
|
table_insert( postgres, Con, RelationName, TypesList, Predicate, LA,
|
|
|
|
( Predicate :- myddas_assert_predicates:
|
|
|
|
( '$get_values_for_insert'(TypesList,LA,ValuesList),
|
|
|
|
'$make_atom'(['INSERT INTO `',RelationName,'` VALUES ('|ValuesList],SQL),
|
|
|
|
postgres_result_set(Mode),
|
|
|
|
'$write_or_not'(SQL),
|
|
|
|
c_postgres_query(SQL,_,Con,Mode,_)))
|
|
|
|
).
|
|
|
|
|
2015-02-14 11:35:07 +00:00
|
|
|
table_insert( sqlite3, Con, RelationName, TypesList, Predicate, LA,
|
|
|
|
( Predicate :- myddas_assert_predicates:
|
|
|
|
( '$get_values_for_insert'(TypesList,LA,ValuesList),
|
|
|
|
'$make_atom'(['INSERT INTO `',RelationName,'` VALUES ('|ValuesList],SQL),
|
2016-07-31 16:02:06 +01:00
|
|
|
sqlite3_result_set(Mode),
|
2015-02-14 11:35:07 +00:00
|
|
|
'$write_or_not'(SQL),
|
|
|
|
c_sqlite3_query(SQL,_,Con,Mode,_)))
|
|
|
|
).
|
|
|
|
|
|
|
|
table_insert( odbc, Con, RelationName, TypesList, Predicate, LA,
|
|
|
|
( Predicate :- myddas_assert_predicates:
|
|
|
|
( '$get_values_for_insert'(TypesList,LA,ValuesList),
|
|
|
|
'$make_atom'(['INSERT INTO `',RelationName,'` VALUES ('|ValuesList],SQL),
|
|
|
|
'$write_or_not'(SQL),
|
|
|
|
c_odbc_my_query(SQL,_,_,_,Con)))
|
|
|
|
).
|
|
|
|
|
|
|
|
|
|
|
|
table_view( mysql, Con, CopyView, CopyGoal, Arity, LA, M,
|
|
|
|
( CopyView :-
|
|
|
|
M:( '$copy_term_nv'(CopyView,[],ProjT,Dic),
|
|
|
|
'$copy_term_nv'(CopyGoal,Dic,NG,_),
|
|
|
|
translate(ProjT,NG,Code),
|
|
|
|
queries_atom(Code,FinalSQL),
|
|
|
|
db_my_result_set(Mode),
|
|
|
|
'$write_or_not'(FinalSQL),
|
|
|
|
c_db_my_query(FinalSQL,ResultSet,Con,Mode,_),
|
|
|
|
!,
|
|
|
|
c_db_my_row(ResultSet,Arity,LA) ))).
|
|
|
|
|
2015-02-16 11:44:37 +00:00
|
|
|
table_view( postgres, Con, CopyView, CopyGoal, Arity, LA, M,
|
|
|
|
( CopyView :-
|
|
|
|
M:( '$copy_term_nv'(CopyView,[],ProjT,Dic),
|
|
|
|
'$copy_term_nv'(CopyGoal,Dic,NG,_),
|
|
|
|
translate(ProjT,NG,Code),
|
|
|
|
queries_atom(Code,FinalSQL),
|
|
|
|
db_my_result_set(Mode),
|
|
|
|
'$write_or_not'(FinalSQL),
|
|
|
|
c_postgres_query(FinalSQL,ResultSet,Con,Mode,_),
|
|
|
|
!,
|
|
|
|
c_postgres_row(ResultSet,Arity,LA) ))).
|
|
|
|
|
2015-02-14 11:35:07 +00:00
|
|
|
table_view( odbc, Con, CopyView, CopyGoal, Arity, LA, M,
|
|
|
|
( CopyView :-
|
|
|
|
M:( '$copy_term_nv'(CopyView,[],ProjT,Dic),
|
|
|
|
'$copy_term_nv'(CopyGoal,Dic,NG,_),
|
|
|
|
translate(ProjT,NG,Code),
|
|
|
|
length(BindList, Arity ),
|
|
|
|
queries_atom(Code,FinalSQL),
|
|
|
|
'$write_or_not'(FinalSQL),
|
2016-07-31 16:02:06 +01:00
|
|
|
c_odbc_query(FinalSQL,ResultSet,Arity,BindList,Con),
|
2015-02-14 11:35:07 +00:00
|
|
|
!,
|
2016-07-31 16:02:06 +01:00
|
|
|
c_odbc_row(ResultSet,Arity,LA) ))).
|
2015-02-14 11:35:07 +00:00
|
|
|
|
|
|
|
table_view( sqlite3, Con, CopyView, CopyGoal, Arity, LA, M,
|
|
|
|
( CopyView :-
|
|
|
|
M:( '$copy_term_nv'(CopyView,[],ProjT,Dic),
|
|
|
|
'$copy_term_nv'(CopyGoal,Dic,NG,_),
|
|
|
|
translate(ProjT,NG,Code),
|
|
|
|
queries_atom(Code,FinalSQL),
|
|
|
|
'$write_or_not'(FinalSQL),
|
|
|
|
c_sqlite3_query(FinalSQL,ResultSet,Con,_,_),
|
|
|
|
!,
|
2016-07-31 16:02:06 +01:00
|
|
|
c_sqlite3_row(ResultSet,Arity,LA) ))).
|