implement Do; include "sys.m"; sys: Sys; include "bufio.m"; bufio : Bufio; Iobuf : import bufio; include "pgbase.m"; include "pg.m"; pg : Pg; Connection : import pg; include "draw.m"; Do: module { init: fn(ctxt: ref Draw->Context, args: list of string); }; init(nil: ref Draw->Context, nil: list of string) { sys = load Sys Sys->PATH; pg = load Pg Pg->PATH; Connection, Recordset : import pg; c := ref Connection; c.user = "www"; c.password = ""; c.database = "study"; if(c.connect("192.168.9.14", "5432", nil, nil)) { if(c.parse("speeder", "SELECT proname, pronargs, proargtypes, proargnames, prorettype, prosrc FROM pg_proc WHERE proowner=$1;", nil)) { portal := ""; name := "speeder"; parameter_format_codes : array of int; parameter_format_codes = nil; # array of int parameters := array[1] of {array of byte "101"}; result_format_codes := array[6] of {0, 0, 0, 0, 0, 0}; # get them all as text rows_to_return := 0; # no limit recordset := c.execute(portal, name, nil, parameters, result_format_codes, rows_to_return); if(recordset == nil) sys->print("recordset nil\n"); else { for(r:=0; r < len recordset.rows; r++) { sys->print("proname %s nargs:%s argtypes:%s argnames:%s returntype:%s src %s\n", string recordset.rows[r][0], string recordset.rows[r][1], string recordset.rows[r][2], string recordset.rows[r][3], string recordset.rows[r][4], string recordset.rows[r][5]); } } } c.disconnect(); } else { sys->print("Connection failed\n"); } } do_sql(c: ref Connection, sql : string) { r := c.query(sql); for(i:= 0; i < len(r.rows); i++) { row := r.rows[i]; for(j:= 0; j < len(row[i]); j++) { sys->print(" %s", string row[i][j]); } sys->print("\n"); } } # Put Limbo do