示例#1
0
        /// <summary>
        /// Constructs the parameter using the DEDB2Parameter instance
        /// </summary>
        /// <param name="paramName"></param>
        /// <param name="paramValue"></param>
        /// <param name="paramType"></param>
        /// <param name="paramDirection"></param>
        /// <returns></returns>
        /// <remarks></remarks>
        protected DEDB2Parameter ConstructDB2Parameter(string paramName, string paramValue, iDB2DbType paramType = iDB2DbType.iDB2Char, ParameterDirection paramDirection = ParameterDirection.Input)
        {
            DEDB2Parameter parameterPiece = new DEDB2Parameter();

            parameterPiece.ParamDirection = paramDirection;
            parameterPiece.ParamName      = paramName;
            parameterPiece.ParamType      = paramType;
            parameterPiece.ParamValue     = paramValue;
            return(parameterPiece);
        }
示例#2
0
        private string GetUseQuotes(DEDB2Parameter param)
        {
            bool isNumeric = param.ParamType == IBM.Data.DB2.iSeries.iDB2DbType.iDB2BigInt |
                             param.ParamType == IBM.Data.DB2.iSeries.iDB2DbType.iDB2Decimal |
                             param.ParamType == IBM.Data.DB2.iSeries.iDB2DbType.iDB2Double |
                             param.ParamType == IBM.Data.DB2.iSeries.iDB2DbType.iDB2Integer |
                             param.ParamType == IBM.Data.DB2.iSeries.iDB2DbType.iDB2Numeric |
                             param.ParamType == IBM.Data.DB2.iSeries.iDB2DbType.iDB2Real |
                             param.ParamType == IBM.Data.DB2.iSeries.iDB2DbType.iDB2SmallInt;

            return(isNumeric ? "No" : "Yes");
        }
示例#3
0
        /// <summary>
        /// Attaches the parameters to the given DB2 command instance
        /// </summary>
        /// <param name="givenDB2Command">The given DB2 command.</param>
        /// <returns></returns>
        private ErrorObj AttachParametersToCommand(iDB2Command givenDB2Command)
        {
            ErrorObj err = new ErrorObj();

            if (!(_commandElement.CommandParameter == null))
            {
                if (_commandElement.CommandParameter.Count > 0)
                {
                    System.Collections.Generic.List <DEDB2Parameter> paramaterList = _commandElement.CommandParameter;
                    DEDB2Parameter parameterPiece = default(DEDB2Parameter);
                    foreach (DEDB2Parameter tempLoopVar_parameterPiece in paramaterList)
                    {
                        parameterPiece = tempLoopVar_parameterPiece;
                        iDB2Parameter tempDB2Parameter = new iDB2Parameter();
                        if ((!(err.HasError)) && HasValue(parameterPiece.ParamName))
                        {
                            tempDB2Parameter.ParameterName = parameterPiece.ParamName;
                        }
                        else
                        {
                            err.HasError     = true;
                            err.ErrorMessage = ERROR_COMMANDPARAMETERNAME;
                            break;
                        }
                        //If paramValue is nothing considering it as DBNull.Value
                        if (parameterPiece.ParamValue == null)
                        {
                            tempDB2Parameter.Value = DBNull.Value;
                        }
                        else
                        {
                            if ((!(err.HasError)) && HasValue(System.Convert.ToString(parameterPiece.ParamValue), parameterPiece.ParamType))
                            {
                                tempDB2Parameter.iDB2DbType = parameterPiece.ParamType;
                                tempDB2Parameter.Value      = parameterPiece.ParamValue;
                            }
                            else
                            {
                                err.HasError     = true;
                                err.ErrorMessage = ERROR_COMMANDPARAMETERTYPEVALUE;
                                break;
                            }
                        }
                        if (!(err.HasError))
                        {
                            if (parameterPiece.ParamDirection == null)
                            {
                                parameterPiece.ParamDirection = ParameterDirection.Input;
                            }
                            tempDB2Parameter.Direction = parameterPiece.ParamDirection;
                        }
                        if (!(err.HasError))
                        {
                            givenDB2Command.Parameters.Add(tempDB2Parameter);
                        }
                        tempDB2Parameter = null;
                    }
                    parameterPiece = null;
                }
            }
            return(err);
        }