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