예제 #1
0
        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
        private SQLRCursor getCursor()
        {
            if (_sqlrcur == null)
            {
                _sqlrcur = new SQLRCursor(_sqlrelaycon.SQLRConnection);

                if (_sqlrelaycon._columnnamecase == "upper")
                {
                    _sqlrcur.upperCaseColumnNames();
                }
                else if (_sqlrelaycon._columnnamecase == "lower")
                {
                    _sqlrcur.lowerCaseColumnNames();
                }

                _sqlrcur.setResultSetBufferSize(_sqlrelaycon._resultsetbuffersize);

                if (_sqlrelaycon._dontgetcolumninfo)
                {
                    _sqlrcur.dontGetColumnInfo();
                }

                if (_sqlrelaycon._nullsasnulls)
                {
                    _sqlrcur.getNullsAsNulls();
                }
            }
            return(_sqlrcur);
        }
예제 #3
0
        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
        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
        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();
예제 #6
0
        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());
            }
        }
예제 #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.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();
예제 #8
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();
예제 #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.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();
예제 #10
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");
            }
        }
예제 #11
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("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();
예제 #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     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();
            }
        }
예제 #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
        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");
            }
        }
예제 #16
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("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");
            }
        }
예제 #17
0
        private void copyOutBindValues()
        {
            for (Int32 i = 0; i < Parameters.Count; i++)
            {
                SQLRelayParameter param = (SQLRelayParameter)Parameters[i];

                if (param.Direction == ParameterDirection.Output)
                {
                    param.Size = _sqlrcur.getOutputBindLength(param.ParameterName);

                    switch (param.SQLRelayType)
                    {
                    case SQLRelayType.Clob:
                        param.Value = _sqlrcur.getOutputBindClob(param.ParameterName);
                        continue;

                    case SQLRelayType.Blob:
                        param.Value = _sqlrcur.getOutputBindBlob(param.ParameterName);
                        continue;

                    case SQLRelayType.Cursor:
                        SQLRCursor cursor = _sqlrcur.getOutputBindCursor(param.ParameterName);
                        if (cursor.fetchFromBindCursor())
                        {
                            param.Value = new SQLRelayDataReader(_sqlrelaycon, cursor, false);
                        }
                        continue;
                    }

                    switch (param.DbType)
                    {
                    case DbType.AnsiString:
                    case DbType.AnsiStringFixedLength:
                    case DbType.String:
                    case DbType.StringFixedLength:
                    case DbType.Time:
                    case DbType.Guid:
                        param.Value = _sqlrcur.getOutputBindString(param.ParameterName);
                        break;

                    case DbType.Date:
                    case DbType.DateTime:
                    case DbType.DateTime2:
                    case DbType.DateTimeOffset:
                        Int16   year        = 0;
                        Int16   month       = 0;
                        Int16   day         = 0;
                        Int16   hour        = 0;
                        Int16   minute      = 0;
                        Int16   second      = 0;
                        Int32   microsecond = 0;
                        String  tz          = null;
                        Boolean isnegative  = false;
                        _sqlrcur.getOutputBindDate(param.ParameterName, out year, out month, out day, out hour, out minute, out second, out microsecond, out tz, out isnegative);
                        param.Value = new DateTime(year, month, day, hour, minute, second, microsecond / 1000);
                        break;

                    case DbType.Binary:
                        param.Value = _sqlrcur.getOutputBindBlob(param.ParameterName);
                        break;

                    case DbType.Boolean:
                        param.Value = _sqlrcur.getOutputBindInteger(param.ParameterName);
                        break;

                    case DbType.Currency:
                    case DbType.Decimal:
                    case DbType.Single:
                    case DbType.Double:
                    case DbType.VarNumeric:
                        param.Value = _sqlrcur.getOutputBindDouble(param.ParameterName);
                        break;

                    case DbType.Byte:
                    case DbType.Int16:
                    case DbType.Int32:
                    case DbType.Int64:
                    case DbType.SByte:
                    case DbType.UInt16:
                    case DbType.UInt32:
                    case DbType.UInt64:
                        param.Value = _sqlrcur.getOutputBindInteger(param.ParameterName);
                        break;

                    case DbType.Object:
                    case DbType.Xml:
                        param.Value = _sqlrcur.getOutputBindString(param.ParameterName);
                        break;
                    }
                }
            }
        }
예제 #18
0
 public static void Main()
 {
     SQLRConnection con = new SQLRConnection("sqlrserver", 9000, "/tmp/example.socket", "user", "password", 0, 1);
     SQLRCursor     cur = new SQLRCursor(con);