diff --git a/examples/example3.scm b/examples/example3.scm index 883f291..54bf76a 100644 --- a/examples/example3.scm +++ b/examples/example3.scm @@ -62,9 +62,11 @@ (define f3 1) -; Creation +; Creation of the kb (kb-create dbms kb1 f3) +; Creation of tables not included in the basic kb. +(kb-create-sde-experiments dbms kb1) ;Insert fact. (set! it "counter2") @@ -158,6 +160,10 @@ (define tb4 "sde_mem_rules") +; We would need this to gather data. +(define tb5 "sde_experiments") + + ; Standard context value to indicate that a rule always resides on sde_rules ; and not sde_meme_rules. (define co "prg0.1") diff --git a/gexsys0.scm b/gexsys0.scm index 4a3ac16..d977c2b 100644 --- a/gexsys0.scm +++ b/gexsys0.scm @@ -35,6 +35,7 @@ kb-create-sde-mem-facts kb-create-sde-prg-rules kb-create-sde-rules + kb-create-sde-experiments kb-query kb-insert-facts kb-insert-default-facts @@ -443,7 +444,28 @@ Prob REAL CONSTRAINT prob_def_val DEFAULT (1) CONSTRAINT prob_bet_0_1 CHECK (Prob >= 0 AND Prob <= 1) ); ") (dbi-close db-obj))) - + + +; kb-create-sde-experiments - creates a table to hold experimental data as +; a string that might later be passed to tables of the kb such as sde_facts. +; ; +; Arguments: +; - p_dbms: database management system to be used. +; - p_kb1: knowledge base name. +; +(define (kb-create-sde-experiments p_dbms p_kb1) + (let ((db-obj (dbi-open p_dbms p_kb1))) + (dbi-query db-obj "DROP TABLE IF EXISTS sde_experiments;") + (dbi-query db-obj "CREATE TABLE sde_experiments ( + Id INTEGER PRIMARY KEY ASC ON CONFLICT ROLLBACK AUTOINCREMENT UNIQUE ON CONFLICT ROLLBACK, + Context TEXT DEFAULT main, + Status TEXT DEFAULT enabled, + Results TEXT (1024) DEFAULT na, + Comments TEXT (256) DEFAULT na, + Timestamp DATETIME DEFAULT (CURRENT_TIMESTAMP) ); + ") + (dbi-close db-obj))) + ; kb-query - Performs a single SQL query on closed knowledge base. Use dbi-query ; directly if the database has been opened.