private Boolean runQuery() { if (_commandtext == null) { return(false); } validConnection(); getCursor(); if (Parameters.Count == 0) { if ((_prepared) ? _sqlrcur.executeQuery() : _sqlrcur.sendQuery(_commandtext)) { return(true); } } else { if (!_prepared) { Prepare(); } bindParameters(); if (_sqlrcur.executeQuery()) { copyOutBindValues(); return(true); } } throw new SQLRelayException(_sqlrcur.errorNumber(), _sqlrcur.errorMessage()); }
public static void Main() { SQLRConnection con = new SQLRConnection("sqlrserver", 9000, "/tmp/example.socket", "user", "password", 0, 1); SQLRCursor cur = new SQLRCursor(con); cur.prepareQuery("select * from mytable where mycolumn>:value"); cur.inputBind("value", 1); cur.executeQuery();
public static void Main() { SQLRConnection con = new SQLRConnection("sqlrserver", 9000, "/tmp/example.socket", "user", "password", 0, 1); SQLRCursor cur = new SQLRCursor(con); cur.executeQuery("create table images (image blob, description clob)"); Byte imagedata[40000];
public static void Main() { SQLRConnection con = new SQLRConnection("sqlrserver", 9000, "/tmp/example.socket", "user", "password", 0, 1); SQLRCursor cur = new SQLRCursor(con); cur.prepareQuery("select * from mytable $(whereclause)") cur.substitution("whereclause", "where stringcol=:stringval and integercol>:integerval and floatcol>floatval"); cur.inputBind("stringval", "true"); cur.inputBind("integerval", 10); cur.inputBind("floatval", 1.1, 2, 1); cur.executeQuery();
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 select image into :image from images; select description into :desc from images; end;"); cur.defineOutputBindBlob("image"); cur.defineOutputBindClob("desc"); cur.executeQuery(); String image = cur.getOutputBindBlob("image"); UInt32 imagelength = cur.getOutputBindLength("image"); String desc = cur.getOutputBindClob("desc"); UInt32 desclength = cur.getOutputBindLength("desc"); con.endSession();
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 :result1:=addTwoIntegers(:integer1,:integer2); :result2=addTwoFloats(:float1,:float2); :result3=convertToString(:integer3); end;"); cur.inputBind("integer1", 10); cur.inputBind("integer2", 20); cur.inputBind("float1", 1.1, 2, 1); cur.inputBind("float2", 2.2, 2, 1); cur.inputBind("integer3", 30); cur.defineOutputBindInteger("result1"); cur.defineOutputBindDouble("result2"); cur.defineOutputBindString("result3", 100); cur.executeQuery(); Int64 result1=cur.getOutputBindInteger("result1"); Double result2=cur.getOutputBindDouble("result2"); String result3=cur.getOutputBindString("result3"); con.endSession();
public static void Main() { SQLRConnection con = new SQLRConnection("sqlrserver", 9000, "/tmp/example.socket", "user", "password", 0, 1); SQLRCursor cursor1 = new SQLRCursor(con); SQLRCursor cursor2 = new SQLRCursor(con); cursor1.setResultSetBufferSize(10); cursor1.sendQuery("select * from my_huge_table"); UInt64 index = 0; while (!cursor1.endOfResultSet()) { cursor2.prepareQuery("insert into my_other_table values (:1,:2,:3)"); cursor2.inputBind("1", cursor1.getField(index, 1)); cursor2.inputBind("2", cursor1.getField(index, 2)); cursor2.inputBind("3", cursor1.getField(index, 3)); cursor2.executeQuery(); } }
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"); } }