Esempio n. 1
0
        internal void PrepareInternal(string sql, PrepareOption flag)
        {
            con.ReconnectIfNeed();

            CubridStream stream = con.Stream;

            stream.RequestPrepare(sql, flag);

            handle = stream.ResponseCode;
            resultCacheLifetime = stream.ReadInt();
            statementType       = (CubridStatementype)stream.ReadByte();
            bindCount           = stream.ReadInt();
            isUpdateable        = (stream.ReadByte() == 1);
            columnCount         = stream.ReadInt();

            Debug.WriteLine("handle = " + handle);
            Debug.WriteLine("resultCacheLifetime = " + resultCacheLifetime);
            Debug.WriteLine("statementType = " + statementType);
            Debug.WriteLine("bindCount = " + bindCount);
            Debug.WriteLine("isUpdateable = " + isUpdateable);
            Debug.WriteLine("columnCount = " + columnCount);

            columnInfos = stream.ReadColumnInfo(columnCount);

            if (bindCount > 0)
            {
                parameters = new CubridParameter[bindCount];
            }

            if (statementType == CubridStatementype.CallStoredProcedure)
            {
                columnCount = bindCount + 1;
            }
        }
Esempio n. 2
0
        internal void GetOutResultSet(int handle)
        {
            CubridStream stream = con.Stream;

            this.handle = stream.RequestOutResultSet(handle); //TODO: check to need to free old handle

            statementType = (CubridStatementype)stream.ReadByte();
            resultCount   = stream.ReadInt();
            isUpdateable  = (stream.ReadByte() == 1);
            columnCount   = stream.ReadInt();

            Debug.WriteLine("handle = " + handle);
            Debug.WriteLine("statementType = " + statementType);
            Debug.WriteLine("isUpdateable = " + isUpdateable);
            Debug.WriteLine("columnCount = " + columnCount);

            columnInfos = stream.ReadColumnInfo(columnCount);
        }
Esempio n. 3
0
        internal void ExecuteInternal()
        {
            if (parameters != null && IsAllParameterBound() == false)
            {
                throw new CubridException("All parameters are not bound.");
            }

            CubridStream stream = con.Stream;

            byte[] paramModes = null;
            byte   fetchFlag  = 0;

            if (statementType == CubridStatementype.CallStoredProcedure && parameters != null)
            {
                paramModes = new byte[parameters.Length];
                for (int i = 0; i < parameters.Length; i++)
                {
                    paramModes[i] = (byte)parameters[i].Direction;
                }
            }

            if (statementType == CubridStatementype.Select)
            {
                fetchFlag = 1;
            }

            int totalTupleCount = stream.RequestExecute(handle, ExecutionOption.Normal, parameters,
                                                        paramModes, fetchFlag, con.AutoCommit);

            cache_reusable = stream.ReadByte();
            resultCount    = stream.ReadInt();

            Debug.WriteLine("cache_reusable = {0}" + cache_reusable);
            Debug.WriteLine("resultCount = {0}" + resultCount);

            resultInfos = stream.ReadResultInfo(resultCount);

            if (statementType == CubridStatementype.Select)
            {
                int fetchCode  = stream.ReadInt();
                int tupleCount = stream.ReadInt();
                cursor = new CubridDataReader(this, handle, totalTupleCount, columnInfos, tupleCount);
            }
        }
Esempio n. 4
0
        internal bool NextResult()
        {
            CubridStream stream = con.Stream;

            int totalTupleCount = stream.RequestNextResult(handle);

            CubridStatementype commandTypeIs = (CubridStatementype)stream.ReadByte();
            bool isUpdatable  = (stream.ReadByte() == 1) ? true : false;
            int  columnNumber = stream.ReadInt();

            columnInfos = stream.ReadColumnInfo(columnNumber);


            if (commandTypeIs == CubridStatementype.Select)
            {
                cursor = new CubridDataReader(this, handle, totalTupleCount, columnInfos);
            }

            return(true);
        }