Ejemplo n.º 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");
Ejemplo n.º 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.sendQuery("select * from my_table");

            cur.sendQuery("select * from my_table");
Ejemplo n.º 3
0
        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());
        }
Ejemplo n.º 4
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());
            }
        }
Ejemplo n.º 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.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();
Ejemplo n.º 6
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< 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< 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< cur.colCount(); i++)
            {
                Console.Write("Name:          ");
                Console.WriteLine(cur.getColumnName(i));
                Console.Write("\n");
            }
        }
Ejemplo n.º 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("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");
            }
        }
Ejemplo n.º 8
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();
            }
        }
Ejemplo n.º 9
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();
            }
        }
Ejemplo n.º 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 (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");
            }
        }