1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
DB : module
{
PATH : con "/dis/lib/db.dis";
# Open the connection to the DB server
# returns (New handle, "") or (nil, "Error Message")
#
open: fn(addr, username, password, dbname: string) :
(ref DB_Handle, list of string);
#
# Opens a connection to an Inferno on the database machine, with the
# specified level of security.
#
connect : fn(addr, alg : string) : (ref Sys->FD, string);
#
# Mounts the file descriptor on dir, then opens the database.
#
dbopen: fn(fd : ref Sys->FD, username, password, dbname : string) :
(ref DB_Handle, list of string);
DB_Handle : adt
{
#
# Open another SQL stream for the same connection.
#
SQLOpen : fn(oldh : self ref DB_Handle) : (int, ref DB_Handle);
SQLClose : fn(dbh : self ref DB_Handle) : int;
# Execute the SQL command
# returns (0, "") or (error code, "Message")
#
SQL: fn(handle: self ref DB_Handle, command: string)
: (int, list of string);
# Check the number of columns of last select command
#
columns: fn(handle: self ref DB_Handle): int;
# Fetch the next row of the selection results.
# returns current row number, or 0
#
nextRow: fn(handle: self ref DB_Handle): int;
# Read the data of column[i] of current row
#
read: fn(handle: self ref DB_Handle, column: int)
: (int, array of byte);
# Write data to be used for parameter[i]
#
write: fn(handle: self ref DB_Handle, column: int,
fieldval: array of byte) : int;
# Title of the column[i]
#
columnTitle: fn(handle: self ref DB_Handle, column: int)
: string;
#error message associated with last command
#
errmsg: fn(handle: self ref DB_Handle): string;
datafd : ref Sys->FD;
sqlconn:int;
sqlstream : int;
lock : chan of int;
};
};
|