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