Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 2003-06-12 (19:02)
From: Christophe TROESTLER <debian00@t...>
Subject: Re: [Caml-list] Dbi: proposal #1
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


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.


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: