Esempio n. 1
0
        public void Execute(string query)
        {
            if (pendingFuture != null)
            {
                throw new InvalidOperationException("The command is already active.");
            }

            IMarshal marshaledQuery = ExplicitString.CreateExecString(connection, query);

            queryType    = QueryType.QT_UNKNOWN;
            affectedRows = prefetchedRows = 0;
            isLastResult = isLastRow = isLastInBatch = false;
            prefetchRow  = currentRow = null;

            object[] parameterRows = new object[1];
            parameterRows[0] = parameterValues;
            Future future = new Future(Service.Execute, GetId(), marshaledQuery, GetId(), parameterRows, null, GetOptions());

            SendRequest(future);
            CLI.ReturnCode rc = ProcessResult(true);

            if (rc != CLI.ReturnCode.SQL_SUCCESS && rc != CLI.ReturnCode.SQL_NO_DATA)
            {
                if (rc != CLI.ReturnCode.SQL_SUCCESS_WITH_INFO)
                {
                    pendingFuture = null;
                    connection.futures.Remove(future);
                }
                Diagnostics.HandleResult(rc, this, connection.OuterConnection);
            }
        }
Esempio n. 2
0
        public void SetParameters(VirtuosoParameterCollection parameters)
        {
            this.parameters = parameters;
            if (parameters == null)
            {
                parameterValues = new object[0];
                return;
            }

            parameterValues = new object[parameters.Count];
            for (int i = 0; i < parameters.Count; i++)
            {
                VirtuosoParameter param = (VirtuosoParameter)parameters[i];
                Debug.WriteLineIf(Switch.Enabled, "  param: " + param.paramName);

                object value = null;
                if (param.Direction == ParameterDirection.Input ||
                    param.Direction == ParameterDirection.InputOutput)
                {
                    value = param.Value;
                    if (param.bufferType == null)
                    {
                        if (param.paramType != null)
                        {
                            param.bufferType = param.paramType.bufferType;
                        }
                        else if (value == null || Convert.IsDBNull(value))
                        {
                            param.bufferType = VirtuosoParameter.defaultType.bufferType;
                        }
                        else
                        {
                            param.bufferType = BufferTypes.InferBufferType(value);
                        }
                        if (param.bufferType == null)
                        {
                            throw new InvalidOperationException("Cannot infer parameter type");
                        }
                    }
                    value = param.bufferType.ConvertValue(param.Value);
                }
                Debug.WriteLineIf(Switch.Enabled, "  value: " + param.Value);
                if (value is System.String)
                {
                    BoxTag tag = (param.DbType == DbType.AnsiString ? BoxTag.DV_STRING : BoxTag.DV_WIDE);
                    parameterValues[i] = ExplicitString.CreateExplicitString((String)value, tag, connection);
                }
                else
                {
                    parameterValues[i] = value;
                }
            }
        }
Esempio n. 3
0
        public static string SwitchOverExplicitString(ExplicitString s)
        {
            switch ((string)s)
            {
            case "First case":
                return("Text1");

            case "Second case":
                return("Text2");

            case "Third case":
                return("Text3");

            case "Fourth case":
                return("Text4");

            case "Fifth case":
                return("Text5");

            case "Sixth case":
                return("Text6");

            case "Seventh case":
                return("Text7");

            case "Eighth case":
                return("Text8");

            case "Ninth case":
                return("Text9");

            case "Tenth case":
                return("Text10");

            case "Eleventh case":
                return("Text11");

            default:
                return("Default");
            }
        }
Esempio n. 4
0
        public void Prepare(string query)
        {
            if (pendingFuture != null)
            {
                throw new InvalidOperationException("The command is already active.");
            }

            IMarshal marshaledQuery = ExplicitString.CreateExecString(connection, query);

            Future future = new Future(Service.Prepare, GetId(), marshaledQuery, 0, GetOptions());

            SendRequest(future);
            CLI.ReturnCode rc = ProcessResult(false);
            if (rc != CLI.ReturnCode.SQL_SUCCESS && rc != CLI.ReturnCode.SQL_NO_DATA)
            {
                if (rc != CLI.ReturnCode.SQL_SUCCESS_WITH_INFO)
                {
                    pendingFuture = null;
                    connection.futures.Remove(future);
                }
                Diagnostics.HandleResult(rc, this, connection.OuterConnection);
            }
        }