コード例 #1
0
ファイル: cs-rsbuffersize.cs プロジェクト: joegana/sqlrelay
        public static void Main()
        {
            SQLRConnection con = new SQLRConnection("sqlrserver", 9000, "/tmp/example.socket", "user", "password", 0, 1);
            SQLRCursor     cur = new SQLRCursor(con);

            cur.setResultSetBufferSize(5);

            cur.sendQuery("select * from my_table");

            Boolean done = false;
            UInt64  row  = 0;
            String  field;

            while (!done)
            {
                for (UInt32 col = 0; col< cur.colCount(); col++)
                {
                    field = cur.getField(row, col);
                    if (field != null)
                    {
                        Console.Write(field);
                        Console.Write(",");
                    }
                    else
                    {
                        done = true;
                    }
                }
                Console.Write("\n");
                row++;
            }

            cur.sendQuery("select * from my_other_table");
コード例 #2
0
        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();
コード例 #3
0
ファイル: cs-bind-lob.cs プロジェクト: joegana/sqlrelay
        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];
コード例 #4
0
ファイル: cs-execute.cs プロジェクト: joegana/sqlrelay
        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");

            cur.sendQuery("select * from my_table");
コード例 #5
0
ファイル: cs-errors.cs プロジェクト: joegana/sqlrelay
        public static void Main()
        {
            SQLRConnection con = new SQLRConnection("sqlrserver", 9000, "/tmp/example.socket", "user", "password", 0, 1);
            SQLRCursor     cur = new SQLRCursor(con);


            if (cur.sendQuery("select * from my_nonexistant_table") != true)
            {
                Console.WriteLine(cur.errorMessage());
            }
        }
コード例 #6
0
ファイル: cs-suspend.cs プロジェクト: joegana/sqlrelay
        public static void Main()
        {
            SQLRConnection con = new SQLRConnection("sqlrserver", 9000, "/tmp/example.socket", "user", "password", 0, 1);
            SQLRCursor     cur = new SQLRCursor(con);

            cur.sendQuery("insert into my_table values (1,2,3)");
            cur.suspendResultSet();
            con.suspendSession();
            UInt16 rs     = cur.getResultSetId();
            UInt16 port   = cur.getConnectionPort();
            String socket = cur.getConnectionSocket();
コード例 #7
0
        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();
コード例 #8
0
ファイル: cs-bind-lob-out.cs プロジェクト: joegana/sqlrelay
		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();
コード例 #9
0
        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");
            }
        }
コード例 #10
0
ファイル: cs-bind-out.cs プロジェクト: joegana/sqlrelay
		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();
コード例 #11
0
        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();
            }
        }
コード例 #12
0
        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();
            }
        }
コード例 #13
0
        public static void Main()
        {
            SQLRConnection con = new SQLRConnection("sqlrserver", 9000, "/tmp/example.socket", "user", "password", 0, 1);
            SQLRCursor     cur = new SQLRCursor(con);

            // column names will be forced to upper case
            cur.upperCaseColumnNames();
            cur.sendQuery("select * from my_table");
            con.endSession();

            for (UInt32 i = 0; i&lt; cur.colCount(); i++)
            {
                Console.Write("Name:          ");
                Console.WriteLine(getColumnName(i));
                Console.Write("\n");
            }

            // column names will be forced to lower case
            cur.lowerCaseColumnNames();
            cur.sendQuery("select * from my_table");
            con.endSession();

            for (UInt32 i = 0; i&lt; cur.colCount(); i++)
            {
                Console.Write("Name:          ");
                Console.WriteLine(cur.getColumnName(i));
                Console.Write("\n");
            }

            // column names will be the same as they are in the database
            cur.mixedCaseColumnNames();
            cur.sendQuery("select * from my_table");
            con.endSession();

            for (UInt32 i = 0; i&lt; cur.colCount(); i++)
            {
                Console.Write("Name:          ");
                Console.WriteLine(cur.getColumnName(i));
                Console.Write("\n");
            }
        }
コード例 #14
0
        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 (UInt32 i = 0; i&lt; cur.colCount(); i++)
            {
                Console.Write("Name:          ");
                Console.WriteLine(cur.getColumnName(i));
                Console.Write("Type:          ");
                Console.WriteLine(cur.getColumnType(i));
                Console.Write("Length:        ");
                Console.WriteLine(cur.getColumnLength(i));
                Console.Write("Precision:     ");
                Console.WriteLine(cur.getColumnPrecision(i));
                Console.Write("Scale:         ");
                Console.WriteLine(cur.getColumnScale(i));
                Console.Write("Longest Field: ");
                Console.WriteLine(cur.getLongest(i));
                Console.Write("Nullable:      ");
                Console.WriteLine(cur.getColumnIsNullable(i));
                Console.Write("Primary Key:   ");
                Console.WriteLine(cur.getColumnIsPrimaryKey(i));
                Console.Write("Unique:        ");
                Console.WriteLine(cur.getColumnIsUnique(i));
                Console.Write("Part of Key:   ");
                Console.WriteLine(cur.getColumnIsPartOfKey(i));
                Console.Write("Unsigned:      ");
                Console.WriteLine(cur.getColumnIsUnsigned(i));
                Console.Write("Zero Filled:   ");
                Console.WriteLine(cur.getColumnIsZeroFilled(i));
                Console.Write("Binary:        ");
                Console.WriteLine(cur.getColumnIsBinary(i));
                Console.Write("Auto Increment:");
                Console.WriteLine(cur.getColumnIsAutoIncrement(i));
                Console.Write("\n");
            }
        }
コード例 #15
0
ファイル: cs-bind-cursor.cs プロジェクト: joegana/sqlrelay
        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&lt; bindcur.rowCount(); i++)
            {
                for (int j = 0; j&lt; bindcur.colCount(); j++)
                {
                    Console.Write(bindcur.getField(i, j));
                    Console.Write(", ");
                }
                Console.Write("\n");
            }
        }
コード例 #16
0
 public static void Main()
 {
     SQLRConnection con = new SQLRConnection("sqlrserver", 9000, "/tmp/example.socket", "user", "password", 0, 1);
     SQLRCursor     cur = new SQLRCursor(con);