caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Damien Pous <Damien.Pous@ens-lyon.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Dbi: proposal #1
Date: 13 Jun 2003 10:12:33 +0200	[thread overview]
Message-ID: <1055491953.7515.13.camel@lamppc21.epfl.ch> (raw)
In-Reply-To: <20030612.210736.101270708.debian00@tiscali.be>

Le jeu 12/06/2003 à 21:07, Christophe TROESTLER a écrit :
> 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

with the CVS Printf.kprintf, you can do something like
<<
type res = int

class ['a] query (q: ('a, unit, string, res) format) = 
object(self)
  method execute = Printf.kprintf self#execute_string q
  method execute_string = String.length (* or sthg more interesting *)
end

class dbh = 
object
  method prepare : 'a. ('a, unit, string, res) format -> 'a query = 
    new query
end

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
>>

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


  reply	other threads:[~2003-06-13  8:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-10 20:10 Christophe TROESTLER
2003-06-11  2:06 ` Nicolas Cannasse
2003-06-12 18:50   ` Christophe TROESTLER
2003-06-11 16:13 ` Richard Jones
2003-06-12 19:07   ` Christophe TROESTLER
2003-06-13  8:12     ` Damien Pous [this message]
2003-06-13 11:01       ` Richard Jones
2003-06-13 14:26       ` Christophe TROESTLER
2003-06-13 11:05   ` Richard Jones
2003-06-13 11:49 Benjamin Geer
2003-06-13 13:45 Benjamin Geer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1055491953.7515.13.camel@lamppc21.epfl.ch \
    --to=damien.pous@ens-lyon.fr \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).