sqlite is always available
This commit is contained in:
parent
7dab812d64
commit
8baaa70cec
@ -15,8 +15,6 @@
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
#if USE_MYDDAS
|
||||
|
||||
//:- load_foreign_files([myddas], [], init_myddas).
|
||||
|
||||
/* Initialize MYDDAS GLOBAL STRUCTURES */
|
||||
@ -129,8 +127,8 @@
|
||||
|
||||
#ifdef MYDDAS_MYSQL
|
||||
:- use_module(myddas_mysql,[
|
||||
db_my_result_set/1,
|
||||
db_datalog_describe/1,
|
||||
db_my_result_set/1,
|
||||
db_datalog_describe/1,
|
||||
db_datalog_describe/2,
|
||||
db_describe/3,
|
||||
db_describe/2,
|
||||
@ -148,19 +146,16 @@
|
||||
db_my_sql_mode/2,
|
||||
db_sql_mode/1,
|
||||
db_sql_mode/2
|
||||
]).
|
||||
]).
|
||||
#endif /* MYDDAS_MYSQL */
|
||||
#ifdef MYDDAS_SQLITE3
|
||||
:- use_module(myddas_sqlite3,[
|
||||
% myddas_mysql.ypp
|
||||
c_sqlite3_connect/4,
|
||||
c_sqlite3_disconnect/1,
|
||||
c_sqlite3_query/5,
|
||||
sqlite3_result_set/1,
|
||||
c_sqlite3_number_of_fields/3
|
||||
|
||||
]).
|
||||
#endif /* MYDDAS_MYSQL */
|
||||
% myddas_mysql.ypp
|
||||
c_sqlite3_connect/4,
|
||||
c_sqlite3_disconnect/1,
|
||||
c_sqlite3_query/5,
|
||||
sqlite3_result_set/1,
|
||||
c_sqlite3_number_of_fields/3
|
||||
]).
|
||||
|
||||
|
||||
:- use_module(myddas_util_predicates,[
|
||||
@ -192,9 +187,9 @@
|
||||
queries_atom/2
|
||||
]).
|
||||
|
||||
:- use_module(lists,[
|
||||
append/3
|
||||
]).
|
||||
:- use_module(library(lists),[
|
||||
append/3
|
||||
]).
|
||||
|
||||
|
||||
|
||||
@ -204,168 +199,6 @@
|
||||
% db_open/4
|
||||
%
|
||||
|
||||
#if 0 // MYDDAS_DECLARATIONS
|
||||
|
||||
:- use_module(library(parameters)).
|
||||
|
||||
:- db_open(Protocol) extra_arguments
|
||||
db=Db,
|
||||
port=Port,
|
||||
socket=Socket,
|
||||
user=User,
|
||||
password=Password,
|
||||
% next arguments all refer to the data access point,
|
||||
% so they are all are mutually exclusive
|
||||
data:file=File,
|
||||
data:host=Host/Db,
|
||||
data:host=Host/Db/Port,
|
||||
data:host=Host/Db/Socket,
|
||||
data:odbc=ODBC_DSN
|
||||
|
||||
/* specify conditions */
|
||||
such_that
|
||||
|
||||
/** implicit, types are conditioned on start
|
||||
|
||||
atom(Db),
|
||||
positive_or_zero_integer(Port),
|
||||
atom(Socket),
|
||||
atom(User),
|
||||
atom(Password),
|
||||
file(File),
|
||||
atom(ODBC_DSN),
|
||||
internet_host(Host), */
|
||||
|
||||
/* general theory, type hierarchy
|
||||
atom(X) ==> nonvar(X),
|
||||
\+ atom(X) * nonvar(X) ==> error(atom, X),
|
||||
var(X) ==> error(var, X),
|
||||
|
||||
internet_host(X) == atom(X),
|
||||
|
||||
integer(X) ==> nonvar(X),
|
||||
\+ integer(X) * nonvar(X) ==> error(integer, X),
|
||||
var(X) ==> error(var, X)
|
||||
|
||||
positive_or_zero_integer(X) ==> integer(X),
|
||||
positive_or_zero_integer(X) ==> positive_or_zero(X)
|
||||
|
||||
positive_or_zero(X) ==> number(X),
|
||||
|
||||
integer(X) ==> number(X),
|
||||
|
||||
float(X) ==> number(X),
|
||||
rational(X) => number(X),
|
||||
number(X) ==> nonvar(X),
|
||||
\+ number(X) * nonvar(X) ==> error(number, X),
|
||||
var(X) ==> error(var, X),
|
||||
*/
|
||||
|
||||
/************
|
||||
this unfolds to
|
||||
P == ( (Protocol = mysql) + Protocol = powstgres + Protocol = odbc + Protocol = sqlite3 ),
|
||||
|
||||
Protocol = mysql ==> \+ Protocol = postgres,
|
||||
Protocol = mysql ==> \+ Protocol = odbc,
|
||||
Protocol = mysql ==> \+ Protocol = sqlite3,
|
||||
Protocol = postgres ==> \+ Protocol = mysql,
|
||||
|
||||
% P(X,D)
|
||||
P ==> atom(Protocol),
|
||||
atom(X) * not P ==> error(domain, X, D),
|
||||
*/
|
||||
|
||||
/* problem specific axioms */
|
||||
Connection?=myddas,
|
||||
Host ?= localhost,
|
||||
User ?= '',
|
||||
Password ?= '',
|
||||
|
||||
|
||||
t_atom(X) =:= atom(X) \/ t_var(X) \/ type_err(atom(X)),
|
||||
t_var(X) =:= err(var(X)),
|
||||
t_integer(X) =:= integer(X) \/ t_var(X) \/ err(integer(X)),
|
||||
i_atom(X) =:= atom(X) \/ i_var(X) \/ t(atom(X)),
|
||||
i_var(X) =:= i(var(X)),
|
||||
i_integer(X) =:= integer(X) \/ i_var(X) \/ err(integer(X)),
|
||||
|
||||
|
||||
( list( X ) =:= ( nil(X) + ( X = cons( A, Y ) * L ) ) ),
|
||||
|
||||
list( Protocol ) .
|
||||
|
||||
/*
|
||||
c_db_c_odbc_connect_connect ==> c_odbc_connect,
|
||||
c_db_my_connect ==> c_db_connect,
|
||||
c_c_postgres_connect_connect ==> c_postgres_connect,
|
||||
c_sqlite3_connect ==> sqlite3.
|
||||
*/
|
||||
|
||||
%c_odbc_connect ==> i_atom( Password ) * i_atom( User ) *
|
||||
|
||||
|
||||
|
||||
(- (c^c_sqlite3_connect(File,User,Password,Handle)) :- (c ^fail) ).
|
||||
|
||||
/*
|
||||
( c^c_db_my_connect(Host,User,Password,Db,Port,Socket,Handle) ==
|
||||
Protocol = odbc
|
||||
(Protocol = mysql) *
|
||||
-(Protocol = sqlite3)*
|
||||
-(Protocol = postgres) ),
|
||||
|
||||
|
||||
% t_internet_host(Host),
|
||||
% i_atom(User) *
|
||||
% i_atom(Password) *
|
||||
% i_positive_or_zero_integer(Port) *
|
||||
% i_atom(Db) *
|
||||
% i_atom(Socket)
|
||||
|
||||
( c^c_odbc_connect(ODBCEntry,User,Password,Handle) ==
|
||||
(Protocol = odbc)*
|
||||
-(Protocol = mysql) *
|
||||
-(Protocol = sqlite3)*
|
||||
-(Protocol = postgres) ),
|
||||
|
||||
|
||||
|
||||
( c^c_postgres_connect(Host/Db/Port/Socket,User,Password, Handle) ==
|
||||
-(Protocol = odbc)*
|
||||
-(Protocol = mysql) *
|
||||
-(Protocol = sqlite3)*
|
||||
(Protocol = posgres) ),
|
||||
|
||||
% t_internet_host(Host)*
|
||||
% i_atom(User) *
|
||||
% i_atom(Password) *
|
||||
% i_positive_or_zero_integer(Port) *
|
||||
% i_atom(Db) *
|
||||
% i_atom(Socket) *
|
||||
|
||||
% 0 is default port and Var to be NULL, the default socket
|
||||
(c^c_sqlite3_connect(File,User,Password,Handle)
|
||||
==
|
||||
-(Protocol = odbc)*
|
||||
-(Protocol = mysql) *
|
||||
(Protocol = sqlite3)*
|
||||
-(Protocol = postgres)).
|
||||
%(Protocol = sqlite3),
|
||||
% t_file( File ) *
|
||||
%
|
||||
% i_atom(User) *
|
||||
% i_atom(Password).
|
||||
/*
|
||||
integer(Handle) ==
|
||||
c^c_db_my_connect(Host,User,Password,Db,Port,Socket,Handle) +
|
||||
c^c_odbc_connect(ODBCEntry,User,Password,Handle) +
|
||||
c^c_postgres_connect(Host/Db/Port/Socket,User,Password, Handle) +
|
||||
c^c_sqlite3_connect(File,User,Password,Handle).
|
||||
*/
|
||||
db_open(Protocol) :- true.
|
||||
|
||||
#else
|
||||
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
@ -409,13 +242,10 @@ db_open(odbc,Connection,ODBCEntry,User,Password) :-
|
||||
c_odbc_connect(ODBCEntry,User,Password,Con),
|
||||
set_value(Connection,Con).
|
||||
#endif
|
||||
#ifdef MYDDAS_SQLITE3
|
||||
db_open(sqlite3,Connection,File,User,Password) :-
|
||||
'$error_checks'(db_open(sqlite3,Connection,File,User,Password)),
|
||||
c_sqlite3_connect(File,User,Password,Con),
|
||||
set_value(Connection,Con).
|
||||
#endif
|
||||
#endif
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
||||
@ -857,4 +687,4 @@ db_multi_queries_number(Connection,Number) :-
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
||||
#endif /*MYDDAS_MYSQL || MYDDAS_ODBC*/
|
||||
|
||||
|
@ -14,34 +14,35 @@
|
||||
* comments: MySQL Predicates *
|
||||
* *
|
||||
*************************************************************************/
|
||||
#ifdef MYDDAS_SQLITE3
|
||||
|
||||
:- module(myddas_sqlite3,[
|
||||
sqlite3_result_set/1,
|
||||
sqlite3_datalog_describe/1,
|
||||
sqlite3_datalog_describe/2,
|
||||
sqlite3_describe/3,
|
||||
sqlite3_describe/2,
|
||||
sqlite3_datalog_show_tables/1,
|
||||
sqlite3_datalog_show_tables/0,
|
||||
sqlite3_show_tables/2,
|
||||
sqlite3_show_tables/1,
|
||||
sqlite3_show_database/2,
|
||||
sqlite3_show_databases/2,
|
||||
sqlite3_show_databases/1,
|
||||
sqlite3_change_database/2,
|
||||
sqlite3_call_procedure/4,
|
||||
sqlite3_call_procedure/3,
|
||||
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
|
||||
#ifdef MYDDAS_ODBC
|
||||
|
||||
:- module(myddas_odbc,[
|
||||
odbc_result_set/1,
|
||||
odbc_datalog_describe/1,
|
||||
odbc_datalog_describe/2,
|
||||
odbc_describe/3,
|
||||
odbc_describe/2,
|
||||
odbc_datalog_show_tables/1,
|
||||
odbc_datalog_show_tables/0,
|
||||
odbc_show_tables/2,
|
||||
odbc_show_tables/1,
|
||||
odbc_show_database/2,
|
||||
odbc_show_databases/2,
|
||||
odbc_show_databases/1,
|
||||
odbc_change_database/2,
|
||||
odbc_call_procedure/4,
|
||||
odbc_call_procedure/3,
|
||||
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
|
||||
]).
|
||||
|
||||
:- use_module(myddas,[
|
||||
@ -59,7 +60,7 @@
|
||||
'$make_a_list'/2,
|
||||
'$write_or_not'/1
|
||||
]).
|
||||
:- load_foreign_files( ['Yapsqlite3'], [], init_sqlite3).
|
||||
:- load_foreign_files( ['Yapodbc'], [], init_odbc).
|
||||
|
||||
%--------------------------------------------------------
|
||||
% Public Predicates
|
||||
@ -67,160 +68,160 @@
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% sqlite3_result_set/1
|
||||
% odbc_result_set/1
|
||||
%
|
||||
%
|
||||
sqlite3_result_set(X):-
|
||||
odbc_result_set(X):-
|
||||
var(X),!,
|
||||
get_value(sqlite3_result_set,X).
|
||||
sqlite3_result_set(use_result):-
|
||||
set_value(sqlite3_result_set,use_result).
|
||||
sqlite3_result_set(store_result):-
|
||||
set_value(sqlite3_result_set,store_result).
|
||||
get_value(odbc_result_set,X).
|
||||
odbc_result_set(use_result):-
|
||||
set_value(odbc_result_set,use_result).
|
||||
odbc_result_set(store_result):-
|
||||
set_value(odbc_result_set,store_result).
|
||||
%default value
|
||||
:- sqlite3_result_set(use_result).
|
||||
:- odbc_result_set(use_result).
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% sqlite3_describe/2
|
||||
% odbc_describe/2
|
||||
%
|
||||
%
|
||||
sqlite3_datalog_describe(Relation):-
|
||||
sqlite3_datalog_describe(myddas,Relation).
|
||||
sqlite3_datalog_describe(Connection,Relation) :-
|
||||
'$error_checks'(sqlite3_datalog_describe(Relation,Connection)),
|
||||
odbc_datalog_describe(Relation):-
|
||||
odbc_datalog_describe(myddas,Relation).
|
||||
odbc_datalog_describe(Connection,Relation) :-
|
||||
'$error_checks'(odbc_datalog_describe(Relation,Connection)),
|
||||
'$get_value'(Connection,Conn),
|
||||
'$make_atom'(['DESCRIBE ',Relation],SQL),
|
||||
sqlite3_result_set(Mode),
|
||||
c_sqlite3_query(SQL,ResultSet,Conn,Mode,_),
|
||||
c_sqlite3_table_write(ResultSet).
|
||||
odbc_result_set(Mode),
|
||||
c_odbc_query(SQL,ResultSet,Conn,Mode,_),
|
||||
c_odbc_table_write(ResultSet).
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% sqlite3_describe/3
|
||||
% sqlite3_describe/2
|
||||
% odbc_describe/3
|
||||
% odbc_describe/2
|
||||
% gives the results of the DESCRIBE statement
|
||||
% by backtracking
|
||||
sqlite3_describe(Relation,TableInfo) :-
|
||||
sqlite3_describe(myddas,Relation,TableInfo).
|
||||
sqlite3_describe(Connection,Relation,tableinfo(A1,A2,A3,A4,A5,A6)) :-
|
||||
'$error_checks'(sqlite3_describe(Relation,Connection,_)),
|
||||
odbc_describe(Relation,TableInfo) :-
|
||||
odbc_describe(myddas,Relation,TableInfo).
|
||||
odbc_describe(Connection,Relation,tableinfo(A1,A2,A3,A4,A5,A6)) :-
|
||||
'$error_checks'(odbc_describe(Relation,Connection,_)),
|
||||
'$get_value'(Connection,Conn),
|
||||
'$make_atom'(['DESCRIBE ',Relation],SQL),
|
||||
sqlite3_result_set(Mode),
|
||||
odbc_result_set(Mode),
|
||||
'$write_or_not'(SQL),
|
||||
c_sqlite3_query(SQL,ResultSet,Conn,Mode,_),
|
||||
c_odbc_query(SQL,ResultSet,Conn,Mode,_),
|
||||
!,
|
||||
c_sqlite3_row(ResultSet,6,[A1,A2,A3,A4,A5,A6]).
|
||||
c_odbc_row(ResultSet,6,[A1,A2,A3,A4,A5,A6]).
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% sqlite3_datalog_show_tables/1
|
||||
% odbc_datalog_show_tables/1
|
||||
%
|
||||
%
|
||||
sqlite3_datalog_show_tables:-
|
||||
sqlite3_datalog_show_tables(myddas).
|
||||
sqlite3_datalog_show_tables(Connection) :-
|
||||
'$error_checks'(sqlite3_show_tables(Connection)),
|
||||
odbc_datalog_show_tables:-
|
||||
odbc_datalog_show_tables(myddas).
|
||||
odbc_datalog_show_tables(Connection) :-
|
||||
'$error_checks'(odbc_show_tables(Connection)),
|
||||
'$get_value'(Connection,Conn),
|
||||
sqlite3_result_set(Mode),
|
||||
odbc_result_set(Mode),
|
||||
'$write_or_not'('.tables'),
|
||||
c_sqlite3_query('.tables',ResultSet,Conn,Mode,_),
|
||||
c_sqlite3_table_write(ResultSet).
|
||||
c_odbc_query('.tables',ResultSet,Conn,Mode,_),
|
||||
c_odbc_table_write(ResultSet).
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% sqlite3_show_tables/2
|
||||
% sqlite3_show_tables/1
|
||||
% odbc_show_tables/2
|
||||
% odbc_show_tables/1
|
||||
% gives the results of the SHOW TABLES statement
|
||||
% by backtracking
|
||||
sqlite3_show_tables(Table) :-
|
||||
sqlite3_show_tables(myddas,Table).
|
||||
sqlite3_show_tables(Connection,table(Table)) :-
|
||||
'$error_checks'(sqlite3_show_tables(Connection)),
|
||||
odbc_show_tables(Table) :-
|
||||
odbc_show_tables(myddas,Table).
|
||||
odbc_show_tables(Connection,table(Table)) :-
|
||||
'$error_checks'(odbc_show_tables(Connection)),
|
||||
'$get_value'(Connection,Conn),
|
||||
sqlite3_result_set(Mode),
|
||||
odbc_result_set(Mode),
|
||||
'$write_or_not'('.tables'),
|
||||
c_sqlite3_query('.tables',ResultSet,Conn,Mode,_),
|
||||
!,c_sqlite3_row(ResultSet,1,[Table]).
|
||||
c_odbc_query('.tables',ResultSet,Conn,Mode,_),
|
||||
!,c_odbc_row(ResultSet,1,[Table]).
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% sqlite3_show_database/2
|
||||
% odbc_show_database/2
|
||||
%
|
||||
%
|
||||
sqlite3_show_database(Connection,Database) :-
|
||||
'$error_checks'(sqlite3_show_database(Connection,Database)),
|
||||
odbc_show_database(Connection,Database) :-
|
||||
'$error_checks'(odbc_show_database(Connection,Database)),
|
||||
'$get_value'(Connection,Con),
|
||||
c_sqlite3_get_database(Con,Database).
|
||||
c_odbc_get_database(Con,Database).
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% sqlite3_show_databases/2
|
||||
% odbc_show_databases/2
|
||||
%
|
||||
%
|
||||
sqlite3_show_databases(Connection,database(Databases)) :-
|
||||
%'$error_checks'(sqlite3_show_databases(Connection,Database)),
|
||||
odbc_show_databases(Connection,database(Databases)) :-
|
||||
%'$error_checks'(odbc_show_databases(Connection,Database)),
|
||||
'$get_value'(Connection,Conn),
|
||||
sqlite3_result_set(Mode),
|
||||
odbc_result_set(Mode),
|
||||
'$write_or_not'('SHOW DATABASES'),
|
||||
c_sqlite3_query('SHOW DATABASES',ResultSet,Conn,Mode,_),
|
||||
!,c_sqlite3_row(ResultSet,1,[Databases]).
|
||||
c_odbc_query('SHOW DATABASES',ResultSet,Conn,Mode,_),
|
||||
!,c_odbc_row(ResultSet,1,[Databases]).
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% sqlite3_show_databases/1
|
||||
% odbc_show_databases/1
|
||||
% TODO Error Checks
|
||||
%
|
||||
sqlite3_show_databases(Connection) :-
|
||||
'$error_checks'(sqlite3_show_databases(Connection)),
|
||||
odbc_show_databases(Connection) :-
|
||||
'$error_checks'(odbc_show_databases(Connection)),
|
||||
'$get_value'(Connection,Conn),
|
||||
sqlite3_result_set(Mode),
|
||||
odbc_result_set(Mode),
|
||||
'$write_or_not'('SHOW DATABASES'),
|
||||
c_sqlite3_query('SHOW DATABASES',ResultSet,Conn,Mode,_),
|
||||
c_sqlite3_table_write(ResultSet).
|
||||
c_odbc_query('SHOW DATABASES',ResultSet,Conn,Mode,_),
|
||||
c_odbc_table_write(ResultSet).
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% sqlite3_change_database/2
|
||||
% odbc_change_database/2
|
||||
%
|
||||
%
|
||||
sqlite3_change_database(Connection,Database) :-
|
||||
'$error_checks'(sqlite3_change_database(Connection,Database)),
|
||||
odbc_change_database(Connection,Database) :-
|
||||
'$error_checks'(odbc_change_database(Connection,Database)),
|
||||
'$get_value'(Connection,Con),
|
||||
'$make_atom'(['USE ',Database],SQL),
|
||||
'$write_or_not'(SQL),
|
||||
c_sqlite3_change_database(Con,Database).
|
||||
c_odbc_change_database(Con,Database).
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% sqlite3_call_procedure/4
|
||||
% sqlite3_call_procedure/3
|
||||
% sqlite3_call_procedure(+,+,+,?)
|
||||
% odbc_call_procedure/4
|
||||
% odbc_call_procedure/3
|
||||
% odbc_call_procedure(+,+,+,?)
|
||||
% Only support in MySQL 5.0 an above
|
||||
% Called procedure must return results via MySQL result set
|
||||
sqlite3_call_procedure(Procedure,Args,Result) :-
|
||||
sqlite3_call_procedure(myddas,Procedure,Args,Result).
|
||||
sqlite3_call_procedure(Connection,Procedure,Args,LA) :-
|
||||
'$error_checks'(sqlite3_call_procedure(Connection,Procedure,Args,LA)),
|
||||
odbc_call_procedure(Procedure,Args,Result) :-
|
||||
odbc_call_procedure(myddas,Procedure,Args,Result).
|
||||
odbc_call_procedure(Connection,Procedure,Args,LA) :-
|
||||
'$error_checks'(odbc_call_procedure(Connection,Procedure,Args,LA)),
|
||||
'$make_atom_args'(Args,ArgsSQL),
|
||||
'$make_atom'(['CALL ',Procedure,'(',ArgsSQL,')'],SQL),
|
||||
sqlite3_sql(Connection,SQL,LA).
|
||||
odbc_sql(Connection,SQL,LA).
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
||||
#endif /* MYDDAS_SQLITE3 */
|
||||
#endif /* MYDDAS_ODBC */
|
Reference in New Issue
Block a user