MYDDAS: New syntax in some predicates

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1553 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
tiagosoares 2006-03-03 14:14:54 +00:00
parent c993c40718
commit e1b2643b62
3 changed files with 74 additions and 32 deletions

View File

@ -32,12 +32,15 @@
db_prolog_select/3,
db_prolog_select_multi/3,
db_command/2,
db_insert/2,
db_assert/2,
db_assert/1,
db_create_table/3,
db_export_view/4,
db_update/2,
db_get_attributes_types/2,
db_get_attributes_types/3,
db_number_of_fields/2,
db_number_of_fields/3,
db_multi_queries_number/2,
@ -51,6 +54,7 @@
db_import/3,
db_view/2,
db_view/3,
db_insert/2,
db_insert/3,
db_abolish/2,
db_listing/0,
@ -64,10 +68,14 @@
db_my_insert/2,
db_my_insert/3,
db_my_result_set/1,
db_my_describe/2,
db_my_describe/3,
db_my_show_tables/1,
db_my_show_tables/2,
db_datalog_describe/1,
db_datalog_describe/2,
db_describe/3,
db_describe/2,
db_datalog_show_tables/1,
db_datalog_show_tables/0,
db_show_tables/2,
db_show_tables/1,
db_show_database/2,
db_show_databases/2,
db_show_databases/1,
@ -87,6 +95,7 @@
db_import/3,
db_view/2,
db_view/3,
db_insert/2,
db_insert/3,
db_abolish/2,
db_listing/0,
@ -101,10 +110,14 @@
db_my_insert/2,
db_my_insert/3,
db_my_result_set/1,
db_my_describe/2,
db_my_describe/3,
db_my_show_tables/1,
db_my_show_tables/2,
db_datalog_describe/1,
db_datalog_describe/2,
db_describe/3,
db_describe/2,
db_datalog_show_tables/1,
db_datalog_show_tables/0,
db_show_tables/2,
db_show_tables/1,
db_show_database/2,
db_show_databases/2,
db_show_databases/1,
@ -221,7 +234,7 @@ db_module(ModuleName):-
% db_is_database_predicate(+,+,+)
%
%
db_is_database_predicate(PredName,Arity,Module):-
db_is_database_predicate(Module,PredName,Arity):-
'$error_checks'(db_is_database_predicate(PredName,Arity,Module)),
c_db_check_if_exists_pred(PredName,Arity,Module).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -249,13 +262,18 @@ db_stats(Connection,List):-
db_sql_select(_,_,_):-
nl,write('Know use db_sql/3 insted of db_sql_select/3'),nl,
halt.
%db_sql_select(_,_,_):-
%nl,write('Know use db_sql/3 insted of db_sql_select/3'),nl,
%halt.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% db_sql(+,+,-)
%
%
%compatibility
db_sql_select(Connection,SQL,LA):-
db_sql(Connection,SQL.LA).
db_sql(SQL,LA):-
db_sql(myddas,SQL,LA).
db_sql(Connection,SQL,LA):-
@ -349,14 +367,17 @@ db_command(Connection,SQL):-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% db_insert/2
% db_assert/2
% db_assert/1
%
%
db_insert(Connection,PredName):-
db_assert(PredName):-
db_assert(myddas,PredName).
db_assert(Connection,PredName):-
translate(PredName,PredName,Code),
'$error_checks'(db_insert2(Connection,PredName,Code)),
'$get_values_for_insert'(Code,ValuesList,RelName),
'$make_atom'(['INSERT INTO ',RelName,' VALUES'|ValuesList],SQL),
'$make_atom'(['INSERT INTO `',RelName,'` VALUES'|ValuesList],SQL),
get_value(Connection,Con),
c_db_connection_type(Con,ConType),
@ -455,8 +476,10 @@ db_update(Connection,WherePred-SetPred):-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% db_get_attributes_types/3
% db_get_attributes_types/2
%
%
db_get_attributes_types(RelationName,TypesList) :-
db_get_attributes_types(myddas,RelationName,TypesList).
db_get_attributes_types(Connection,RelationName,TypesList) :-
'$error_checks'(db_get_attributes_types(Connection,RelationName,TypesList)),
get_value(Connection,Con),
@ -481,6 +504,8 @@ db_get_attributes_types(Connection,RelationName,TypesList) :-
% db_number_of_fields/3
%
%
db_number_of_fields(RelationName,Arity) :-
db_number_of_fields(myddas,RelationName,Arity).
db_number_of_fields(Connection,RelationName,Arity) :-
'$error_checks'(db_number_of_fields(Connection,RelationName,Arity)),
get_value(Connection,Con),

View File

@ -20,6 +20,7 @@
db_import/3,
db_view/2,
db_view/3,
db_insert/2,
db_insert/3,
db_abolish/2,
db_listing/0,
@ -61,7 +62,7 @@
% db_import/2
%
db_import(RelationName,PredName):-
db_import(myddas,Relation,PredName).
db_import(myddas,RelationName,PredName).
db_import(Connection,RelationName,PredName) :-
'$error_checks'(db_import(Connection,RelationName,PredName)),
get_value(Connection,Con),
@ -180,6 +181,8 @@ db_view(Connection,PredName,DbGoal) :-
% db_insert/3
%
%
db_insert(RelationName,PredName) :-
db_insert(myddas,RelationName,PredName).
db_insert(Connection,RelationName,PredName) :-
'$error_checks'(db_insert3(Connection,RelationName,PredName)),
get_value(Connection,Con),
@ -210,14 +213,14 @@ db_insert(Connection,RelationName,PredName) :-
( ConType == mysql ->
c_db_my_get_attributes_types(RelationName,Con,TypesList),
Assert =..[':-',Predicate,','(myddas_assert_predicates:'$get_values_for_insert'(TypesList,LA,ValuesList),
','(myddas_assert_predicates:'$make_atom'(['INSERT INTO ',RelationName,' VALUES ('|ValuesList],SQL),
','(myddas_assert_predicates:'$make_atom'(['INSERT INTO `',RelationName,'` VALUES ('|ValuesList],SQL),
','(myddas_assert_predicates:db_my_result_set(Mode),
','(myddas_assert_predicates:'$write_or_not'(SQL),
myddas_assert_predicates:c_db_my_query(SQL,_,Con,Mode)))))]
;
c_db_odbc_get_attributes_types(RelationName,Con,TypesList),
Assert =..[':-',Predicate,','(myddas_assert_predicates:'$get_values_for_insert'(TypesList,LA,ValuesList),
','(myddas_assert_predicates:'$make_atom'(['INSERT INTO ',RelationName,' VALUES ('|ValuesList],SQL),
','(myddas_assert_predicates:'$make_atom'(['INSERT INTO `',RelationName,'` VALUES ('|ValuesList],SQL),
','(myddas_assert_predicates:'$write_or_not'(SQL),
myddas_assert_predicates:c_db_odbc_query(SQL,_,_,_,Con))))]
),

View File

@ -23,10 +23,14 @@
db_my_insert/2,
db_my_insert/3,
db_my_result_set/1,
db_my_describe/2,
db_my_describe/3,
db_my_show_tables/1,
db_my_show_tables/2,
db_datalog_describe/1,
db_datalog_describe/2,
db_describe/3,
db_describe/2,
db_datalog_show_tables/1,
db_datalog_show_tables/0,
db_show_tables/2,
db_show_tables/1,
db_show_database/2,
db_show_databases/2,
db_show_databases/1,
@ -146,7 +150,9 @@ db_my_result_set(store_result):-
% db_my_describe/2
%
%
db_my_describe(Relation,Connection) :-
db_datalog_describe(Relation):-
db_datalog_describe(myddas,Relation).
db_datalog_describe(Connection,Relation) :-
'$error_checks'(db_my_describe(Relation,Connection)),
'$get_value'(Connection,Conn),
'$make_atom'(['DESCRIBE ',Relation],SQL),
@ -158,10 +164,13 @@ db_my_describe(Relation,Connection) :-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% db_my_describe/3
% db_describe/3
% db_describe/2
% gives the results of the DESCRIBE statement
% by backtracking
db_my_describe(Relation,Connection,tableinfo(A1,A2,A3,A4,A5,A6)) :-
db_describe(Relation,TableInfo) :-
db_describe(myddas,Relation,TableInfo).
db_describe(Connection,Relation,tableinfo(A1,A2,A3,A4,A5,A6)) :-
'$error_checks'(db_my_describe(Relation,Connection)),
'$get_value'(Connection,Conn),
'$make_atom'(['DESCRIBE ',Relation],SQL),
@ -174,10 +183,12 @@ db_my_describe(Relation,Connection,tableinfo(A1,A2,A3,A4,A5,A6)) :-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% db_my_show_tables/1
% db_datalog_show_tables/1
%
%
db_my_show_tables(Connection) :-
db_datalog_show_tables:-
db_datalog_show_tables(myddas).
db_datalog_show_tables(Connection) :-
'$error_checks'(db_my_show_tables(Connection)),
'$get_value'(Connection,Conn),
db_my_result_set(Mode),
@ -189,10 +200,13 @@ db_my_show_tables(Connection) :-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% db_my_show_tables/2
% db_show_tables/2
% db_show_tables/1
% gives the results of the SHOW TABLES statement
% by backtracking
db_my_show_tables(Connection,table(Table)) :-
db_show_tables(Table) :-
db_show_tables(myddas,Table).
db_show_tables(Connection,table(Table)) :-
'$error_checks'(db_my_show_tables(Connection)),
'$get_value'(Connection,Conn),
db_my_result_set(Mode),