How to implement with-dbms? 
Author Message
 How to implement with-dbms?

Hi!

I'm trying to implement Harlequins DBMS library, using mysql as the
specific backend. Now the DBMS library has a macro with-dbms. The idea
is that you say:

let dbms = make(<odbc-dbms>);
  with-dbms(dbms)
    let user = make(<user>,
     name: "foo", password: "bar");
    let db = make(<database>,
    datasource-name: "db.world");
    let connection = connect(db, user);
    ...
  end with-dbms;

instead of

let dbms = make(<odbc-dbms>);
let user = make(<odbc-user>,
  name: "foo".
  password: "bar");
let db = make (<odbc-database>, datasource-name: "db.world");
let connection = connect(db, user, dbms: dbms);
..

In other words, within the body of the with-dbms macro
make(<user>,...) and make(<database>,...) will automatically
instantiate objects of the right database type (<odbc-user> and
<odbc-database> in this case).

My question is now what the best way to implement the with-dbms macro
is. Should I introduce a global variable that communicates the type of
the database to make? Or re-bind <user> and <database>?

Andreas

--
"We show that all proposed quantum bit commitment schemes are insecure because
the sender, Alice, can almost always cheat successfully by using an
Einstein-Podolsky-Rosen type of attack and delaying her measurement until she
opens her commitment." ( http://www.*-*-*.com/ )



Wed, 30 Jan 2002 03:00:00 GMT  
 How to implement with-dbms?

Quote:

> My question is now what the best way to implement the with-dbms macro
> is. Should I introduce a global variable that communicates the type of
> the database to make? Or re-bind <user> and <database>?

Are you asking how to implement the with-dbms macro, or how to have
the existing with-dbms macro know how to create the correct type of
<user> and <database> for your database back end?

If the latter, with the sql library that ships with Harlequin, there
is a generic function 'make-dbms-specific' in the 'sql' library:

define open generic make-dbms-specific
    (type :: <class>, dbms :: <dbms>, #rest more-args)
 => (instance :: <object>);

Add methods to this for <user> and <database> for your <dbms> type:

define method make-dbms-specific(
    type == <user>,
    dbms :: <my-dbms>,
    #rest args) => (user :: <my-user>)
  apply(make, <my-user>, args);
end method;

define method make-dbms-specific(
    type == <database>,
    dbms :: <my-dbms>,
    #rest args) => (user :: <my-database>)
  apply(make, <my-database>, args);
end method;

define method make-dbms-specific(
    type == <sql-statement>,
    dbms :: <my-dbms>,
    #rest args) => (user :: <my-database>)
  apply(make, <my-sql-statement>, args);
end method;

All the macros like 'with-dbms', 'with-database', etc will now work
for your back end.

The 'sql' library specialises 'make' for <user>, etc to call
'make-dbms-specific' for the current dbms, which is stored in a global
- the global being set by 'with-dbms' using 'dynamic-bind'.

Does that help?

Chris.



Thu, 31 Jan 2002 03:00:00 GMT  
 How to implement with-dbms?

Quote:

> Are you asking how to implement the with-dbms macro, or how to have
> the existing with-dbms macro know how to create the correct type of
> <user> and <database> for your database back end?

Actually I was only asking what the best way to implement with-dbms
was. I came up with my own protocol between with-dbms and make, but of
course it makes sense to use a protocol compatible to Harlequin's. So
I've implemented theirs now.

Quote:
> The 'sql' library specialises 'make' for <user>, etc to call
> 'make-dbms-specific' for the current dbms, which is stored in a global
> - the global being set by 'with-dbms' using 'dynamic-bind'.

Hm, we have no dynamic-bind in Gwydion Dylan at the moment. So I'm
using an ordinary global holding a queue until we get a decent threads
implementation.

Andreas

--
"We show that all proposed quantum bit commitment schemes are insecure because
the sender, Alice, can almost always cheat successfully by using an
Einstein-Podolsky-Rosen type of attack and delaying her measurement until she
opens her commitment." ( http://xxx.lanl.gov/abs/quant-ph/9603004 )



Thu, 31 Jan 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Matisse 6.0 DBMS Supports VisualWorks 7

2. Search for Object-Oriented DBMS

3. Btrieve/relational DBMS

4. DBMS extensions for Smalltalk st80?

5. Clarification on SQL/DBMS/DBF's

6. What DBMS do you use with Clarion?

7. Check out DBMS World !!!

8. CW Review in DBMS

9. DBMS Integration

10. What features do we want in a DBMS?

11. DBMS/clipper/dBase dream team for remote job

12. DBMS tools for Win32forth

 

 
Powered by phpBB® Forum Software