~ubuntu-branches/ubuntu/intrepid/ocaml-sqlite3/intrepid

« back to all changes in this revision

Viewing changes to sqlite3.ml

  • Committer: Bazaar Package Importer
  • Author(s): Samuel Mimram
  • Date: 2007-09-16 16:50:04 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070916165004-dmp3myxzcqxp045u
Tags: 0.23.0-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
188
188
let row_names stmt = Array.init (data_count stmt) (column_name stmt)
189
189
let row_decltypes stmt = Array.init (data_count stmt) (column_decltype stmt)
190
190
 
191
 
let exec_sql db sql f =
192
 
  let rec loop stmt =
193
 
    if step stmt = Rc.ROW then (
194
 
      f stmt;
195
 
      match prepare_tail stmt with
196
 
      | Some stmt -> loop stmt
197
 
      | None -> ())
198
 
    else ()
199
 
  in
200
 
  loop (prepare db sql)
 
191
 
 
192
(* Function registration *)
 
193
 
 
194
external create_function :
 
195
  db -> string -> int -> (Data.t array -> Data.t) -> unit =
 
196
  "caml_sqlite3_create_function"
 
197
 
 
198
let create_funN db name f = create_function db name (-1) f
 
199
let create_fun0 db name f = create_function db name 0 (fun _ -> f ())
 
200
let create_fun1 db name f = create_function db name 1 (fun args -> f args.(0))
 
201
 
 
202
let create_fun2 db name f =
 
203
  create_function db name 2 (fun args -> f args.(0) args.(1))
 
204
 
 
205
let create_fun3 db name f =
 
206
  create_function db name 3 (fun args -> f args.(0) args.(1) args.(2))
 
207
 
 
208
external delete_function : db -> string -> unit = "caml_sqlite3_delete_function"
201
209
 
202
210
 
203
211
(* Initialisation *)