Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Dbi: proposal #1
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Christophe TROESTLER <debian00@t...>
Subject: Re: [Caml-list] Dbi: proposal #1
On 13 Jun 2003, Damien Pous <Damien.Pous@ens-lyon.fr> wrote:
> 
> with the CVS Printf.kprintf, you can do something like
> [...]
> let dbh = new dbh
> let q1 = dbh#prepare "toto %d"
> let q2 = dbh#prepare "titi %s %f"
> let a1 = q1#execute 1000 
> let a2 = q2#execute "arf" 3.3

Well, this has several drawbacks.  First, the strings are not properly
escaped w.r.t. the database rules.  For example, you must write

INSERT INTO table(a,b) VALUES ('a\'b', NULL)

but with kprintf "a'b" will not be properly escaped.  (This is a
common mistake people do with the PHP approach.)  There is also no
nice way to handle NULL values, to support transparently all SQL92
types (what about DATE, TIMESTAMP, DECIMAL,...) nor to add new types
(want to decode Mysql sets; want to store closures?).  No optimization
of the query is possible.  Finally, this syntax is not compatible with
standard prepared queries (prepared queries are even mandatory for
Oracle I've been told) -- if the database supports prepared queries,
the DB mechanism should be used.

Cheers,
ChriS

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners