From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id VAA01022; Thu, 12 Jun 2003 21:02:36 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id VAA00160 for ; Thu, 12 Jun 2003 21:02:35 +0200 (MET DST) Received: from abel.swapping.umh.ac.be (nat.umh.ac.be [193.190.193.1]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h5CJ2YH19577 for ; Thu, 12 Jun 2003 21:02:34 +0200 (MET DST) Received: from abel.swapping.umh.ac.be ([127.0.0.1] helo=localhost ident=trch) by abel.swapping.umh.ac.be with esmtp (Exim 3.36 #1 (Debian)) id 19QXQ9-0005vF-00; Thu, 12 Jun 2003 21:07:37 +0200 Date: Thu, 12 Jun 2003 21:07:36 +0200 (CEST) Message-Id: <20030612.210736.101270708.debian00@tiscali.be> To: rich@annexia.org Cc: caml-list@inria.fr Subject: Re: [Caml-list] Dbi: proposal #1 From: Christophe TROESTLER In-Reply-To: <20030611161339.GA6982@redhat.com> References: <20030610.221041.13383166.debian00@tiscali.be> <20030611161339.GA6982@redhat.com> Organization: None X-Spook: Cocaine CDC Firewalls Elvis Comirex virus defense information warfare Taiwan beanpole Blowpipe X-Mailer-URL: http://www.mew.org/ X-Operating-System: GNU/Linux (http://www.linux.org/) X-Blessing: Om Ah Hum Vajra Guru Pema Siddhi Hum X-Mailer: Mew version 3.3rc1 on Emacs 21.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; troestler:01 tiscali:99 caml-list:01 dbi:99 dbh:99 salary:01 implemented:01 equivalently:01 type-safe:01 chris:01 christophe:01 ocaml:01 int:01 objects:02 manually:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, 11 Jun 2003, Richard Jones wrote: > > I wish I knew enough OCaml to make some really insightful comments > about this, but in general it looks OK. One question: do you provide > placeholders in the string argument to prepare, eg: > > let query = dbh#prepare "select salary from employees where salary < ?" in You can do that (even though it is not yet implemented in a safe way; normally the DB should support that, in case it does not I'd like to develop some functions to help). > let res = query#execute 10000 in Well, you cannot quite do that since (as you noted) you must know the type of the argument. Actually you have two choices: either you convert your arguments manually to the [string option array] format or you specify the type. Here you can equivalently write either let res = dbh#raw_exec query [| Some(string_of_int 10000) |] in or let res = dbh#exec query (t#int) 10000 in > (Note I couldn't really understand why you would call dbh#raw_exec > instead of some method on query itself, so I changed that). We could. I just want to create few objects. But why not, this is to be discussed. > To make this type-safe you might need to add type information to the > placeholders, eg. "select ... where salary < ?:int" See above. Regards, 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