/// <summary>
 /// Resets this reader to before the first row.
 /// </summary>
 internal void BeforeFirst()
 {
     m_isInitialized = false;
     m_currentRecord = null;
     m_stringValues  = null;
     m_currentRow    = 0;
 }
Example #2
0
        /// <summary>
        /// Prepares the specified SQL character sequence,
        /// returning an <see cref="HsqlStatement"/>
        /// object encapsulating the compiled form.
        /// </summary>
        /// <param name="sql">The SQL character sequence to prepare.</param>
        /// <returns>
        /// The compiled form of the given SQL character sequence.
        /// </returns>
        internal HsqlStatement PrepareStatement(string sql)
        {
            Request  request  = s_protocol.CreatePrepareStatementRequest(sql);
            Response response = Execute(request);

            // TODO: A bit messy to sit here on the .NET side?
            //       Perhaps encapsulate some of this in HsqlProtocol

            org.hsqldb.Record root = response.rRoot;

            PrepareAck pAck        = (PrepareAck)root.data[0];
            int        statementId = s_protocol.GetStatementId(pAck);

            ResultDescriptor resultDescriptor
                = (ResultDescriptor)root.next.data[0];

            ParameterDescriptor parameterDescriptor
                = (ParameterDescriptor)root.next.next.data[0];

            return(new HsqlStatement(statementId, resultDescriptor,
                                     parameterDescriptor));
        }
 /// <summary>
 /// Resets this reader to before the first row.
 /// </summary>
 internal void BeforeFirst()
 {
     m_isInitialized = false;
     m_currentRecord = null;
     m_stringValues = null;
     m_currentRow = 0;
 }
Example #4
0
        internal static void DebugResponse(Response response)
        {
#if DEBUG
            int responseType = s_protocol.GetType(response);

            switch (responseType)
            {
            case ResponseType.UPDATECOUNT:
            {
                Debug0("response: updatecount: {0}",
                       s_protocol.GetUpdateCount(response));
                break;
            }

            case ResponseType.DATA:
            {
                Debug0("response: data:\n {0}",
                       ResultMetaDataToString(response.metaData));
                break;
            }

            case ResponseType.ERROR:
            {
                HsqlException hex = new HsqlException(response);

                int    errorCode = hex.getErrorCode();
                string sqlState  = hex.getSQLState();
                string message   = hex.getMessage();

                Debug0("response: error: [{0}] [{1}] {2}",
                       errorCode, sqlState, message);
                break;
            }

            case ResponseType.MULTI:
            {
                Debug0("response: multi...");

                Record record = response.rRoot;

                int count = 0;

                while (record != null)
                {
                    response = record.data[0] as Response;

                    if (response != null)
                    {
                        count++;

                        Debug0("multi response {0}:", count);
                        DebugResponse(response);
                    }
                }

                break;
            }

            case ResponseType.SQLEXECUTE:
            {
                Debug0("response: sqlexecute");
                // TODO:
                //
                // Basically, we need to know the responseType of
                // request to which this is a response, before we
                // can interpret the rest of the response
                // properly.  The request could have been
                // to prepare a statement, to execute a batch,
                // etc.
                break;
            }

            default:
            {
                Debug0("response: responseType {0}", responseType);

                break;
            }
            }
#endif
        }