/** Sends the CommandText to the SQLRelayConnection and returns the * first column of the first row in the result set returned by the * query. Additional columns or rows are ignored. */ public Object ExecuteScalar() { if (runQuery()) { if (_sqlrcur.rowCount() == 0) { return(null); } return(SQLRelayDataReader.convertField(_sqlrcur.getFieldAsByteArray(0, 0), _sqlrcur.getColumnType(0), _sqlrcur.getColumnPrecision(0), _sqlrcur.getColumnScale(0))); } return(null); }
public static void Main() { SQLRConnection con = new SQLRConnection("sqlrserver", 9000, "/tmp/example.socket", "user", "password", 0, 1); SQLRCursor cur = new SQLRCursor(con); cur.sendQuery("select * from my_table"); con.endSession(); for (UInt64 row = 0; row< cur.rowCount(); row++) { for (UInt32 col = 0; col< cur.colCount(); col++) { Console.Write(cur.getField(row, col)); Console.Write(","); } Console.Write("\n"); } }
public static void Main() { SQLRConnection sqlrcon = new SQLRConnection( "examplehost", 9000, "/tmp/example.socket", "exampleuser", "examplepassword", 0, 1); SQLRCursor sqlrcur = new SQLRCursor(sqlrcon); sqlrcur.sendQuery("select * from exampletable"); for (UInt64 row = 0; row < sqlrcur.rowCount(); row++) { for (UInt64 col = 0; col < sqlrcur.colCount(); col++) { Console.WriteLine(sqlrcur.getField(row, col) + ","); } Console.WriteLine(); } }
public static void Main() { SQLRConnection con = new SQLRConnection("sqlrserver", 9000, "/tmp/example.socket", "user", "password", 0, 1); SQLRCursor cur = new SQLRCursor(con); cur.prepareQuery("begin :curs:=sp_mytable; end;"); cur.defineOutputBindCursor("curs"); cur.executeQuery(); SQLRCursor bindcur = cur.getOutputBindCursor("curs"); bindcur.fetchFromBindCursor(); // print fields from table for (int i = 0; i< bindcur.rowCount(); i++) { for (int j = 0; j< bindcur.colCount(); j++) { Console.Write(bindcur.getField(i, j)); Console.Write(", "); } Console.Write("\n"); } }