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 KAA15737; Fri, 13 Jun 2003 10:12:37 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA15828 for ; Fri, 13 Jun 2003 10:12:36 +0200 (MET DST) Received: from mail0.epfl.ch (mail0.epfl.ch [128.178.50.57]) by nez-perce.inria.fr (8.11.1/8.11.1) with SMTP id h5D8CZT14082 for ; Fri, 13 Jun 2003 10:12:35 +0200 (MET DST) Received: (qmail 13676 invoked from network); 13 Jun 2003 08:12:33 -0000 Received: from lamppc21.epfl.ch (128.178.154.26) by mail0.epfl.ch with SMTP; 13 Jun 2003 08:12:33 -0000 Subject: Re: [Caml-list] Dbi: proposal #1 From: Damien Pous To: caml-list@inria.fr In-Reply-To: <20030612.210736.101270708.debian00@tiscali.be> References: <20030610.221041.13383166.debian00@tiscali.be> <20030611161339.GA6982@redhat.com> <20030612.210736.101270708.debian00@tiscali.be> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Mailer: Ximian Evolution 1.0.8 (1.0.8-11) Date: 13 Jun 2003 10:12:33 +0200 Message-Id: <1055491953.7515.13.camel@lamppc21.epfl.ch> Mime-Version: 1.0 X-Spam: no; 0.00; damien:01 ens-lyon:01 caml-list:01 dbi:99 troestler:01 equivalently:01 dbh:99 printf:01 kprintf:01 toto:01 arf:01 3.3:99 christophe:01 int:01 titi:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Le jeu 12/06/2003 =C3=A0 21:07, Christophe TROESTLER a =C3=A9crit : > 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 =3D dbh#raw_exec query [| Some(string_of_int 10000) |] in > or > let res =3D dbh#exec query (t#int) 10000 in with the CVS Printf.kprintf, you can do something like << type res =3D int class ['a] query (q: ('a, unit, string, res) format) =3D=20 object(self) method execute =3D Printf.kprintf self#execute_string q method execute_string =3D String.length (* or sthg more interesting *) end class dbh =3D=20 object method prepare : 'a. ('a, unit, string, res) format -> 'a query =3D=20 new query end let dbh =3D new dbh let q1 =3D dbh#prepare "toto %d" let q2 =3D dbh#prepare "titi %s %f" let a1 =3D q1#execute 1000=20 let a2 =3D q2#execute "arf" 3.3 >> if you are not using the cvs version, you can still use exceptions, but this becomes quite ugly hope this helps, damien ------------------- 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