예제 #1
0
        /// <summary>
        /// Adds an Non-Unicode variable character parameter to the procedure.
        /// Strings longer than Sql.MAX_VARCHAR_LENGTH and the length argument are truncated to fit.
        /// </summary>
        /// <param name="name">The name of the parameter to add.</param>
        /// <param name="value">The value of the parameter to add.</param>
        /// <param name="length">The length of the variable character parameter.</param>
        /// <param name="direction">The direction of the parameter. Use one of the class parameter constants. Defaults to IN.</param>
        /// <returns>True if the parameter is added, false otherwise.</returns>
        public override bool AddVarCharParameter(string name, string value, int length, ParameterType direction)
        {
            // Truncate the string value if necessary.
            if (!string.IsNullOrWhiteSpace(value) && length != MAX_VARCHAR_SIZE)
            {
                OracleUtility utility = new OracleUtility();
                if (value.Length > utility.MAX_VARCHAR_LENGTH)
                {
                    value = value.Substring(0, utility.MAX_VARCHAR_LENGTH);
                }
            }

            // Check whether to return a MAX sized parameter.
            if (length != MAX_VARCHAR_SIZE)
            {
                // The parameter fits the requirements for a normal nvarchar parameter.
                // Set the size of the parameter to the length of the string because each
                // ANSI character is 1 byte long.
                return(AddParameter(name, value, DbType.String, typeof(OracleParameter), direction, length));
            }
            else
            {
                // The parameter is too large for a normal nvarchar parameter.
                // Create a MAX sized parameter and set the size to the special value associated with max sized parameters.
                return(AddParameter(name, value, DbType.String, typeof(OracleParameter), direction, MAX_VARCHAR_SIZE));
            }
        }
예제 #2
0
        /// <summary>
        /// Adds an Unicode fixed length character parameter to the procedure.
        /// Strings longer than Sql.MAX_NVARCHAR_LENGTH and the length argument are truncated to fit.
        /// </summary>
        /// <param name="name">The name of the parameter to add.</param>
        /// <param name="value">The value of the parameter to add.</param>
        /// <param name="length">The length of the variable character parameter.</param>
        /// <param name="direction">The direction of the parameter. Use one of the class parameter constants. Defaults to IN.</param>
        /// <returns>True if the parameter is added, false otherwise.</returns>
        public override bool AddNCharParameter(string name, string value, int length, ParameterType direction)
        {
            // Truncate the string value if necessary.
            if (!string.IsNullOrWhiteSpace(value))
            {
                OracleUtility utility = new OracleUtility();
                if (value.Length > utility.MAX_NCHAR_LENGTH)
                {
                    value = value.Substring(0, utility.MAX_NVARCHAR_LENGTH);
                }
            }

            // Set the size of the parameter to twice the length of the string because each
            // Unicode character is 2 bytes long.
            return(AddParameter(name, value, DbType.String, typeof(OracleParameter), direction, length * 2));
        }
예제 #3
0
        /// <summary>
        /// Adds an Non-Unicode variable character parameter to the procedure.
        /// Strings longer than Sql.MAX_VARCHAR_LENGTH and the length argument are truncated to fit.
        /// </summary>
        /// <param name="name">The name of the parameter to add.</param>
        /// <param name="value">The value of the parameter to add.</param>
        /// <param name="length">The length of the variable character parameter.</param>
        /// <param name="direction">The direction of the parameter. Use one of the class parameter constants. Defaults to IN.</param>
        /// <returns>True if the parameter is added, false otherwise.</returns>
        public override bool AddVarCharParameter(string name, string value, int length, ParameterType direction)
        {
            // Truncate the string value if necessary.
            if (!string.IsNullOrWhiteSpace(value) && length != MAX_VARCHAR_SIZE)
            {
                OracleUtility utility = new OracleUtility();
                if (value.Length > utility.MAX_VARCHAR_LENGTH)
                {
                    value = value.Substring(0, utility.MAX_VARCHAR_LENGTH);
                }
            }

            // Check whether to return a MAX sized parameter.
            if (length != MAX_VARCHAR_SIZE)
            {
                // The parameter fits the requirements for a normal nvarchar parameter.
                // Set the size of the parameter to the length of the string because each
                // ANSI character is 1 byte long.
                return AddParameter(name, value, DbType.String, typeof(OracleParameter), direction, length);
            }
            else
            {
                // The parameter is too large for a normal nvarchar parameter.
                // Create a MAX sized parameter and set the size to the special value associated with max sized parameters.
                return AddParameter(name, value, DbType.String, typeof(OracleParameter), direction, MAX_VARCHAR_SIZE);
            }
        }
예제 #4
0
        /// <summary>
        /// Adds an Unicode fixed length character parameter to the procedure.
        /// Strings longer than Sql.MAX_NVARCHAR_LENGTH and the length argument are truncated to fit.
        /// </summary>
        /// <param name="name">The name of the parameter to add.</param>
        /// <param name="value">The value of the parameter to add.</param>
        /// <param name="length">The length of the variable character parameter.</param>
        /// <param name="direction">The direction of the parameter. Use one of the class parameter constants. Defaults to IN.</param>
        /// <returns>True if the parameter is added, false otherwise.</returns>
        public override bool AddNCharParameter(string name, string value, int length, ParameterType direction)
        {
            // Truncate the string value if necessary.
            if (!string.IsNullOrWhiteSpace(value))
            {
                OracleUtility utility = new OracleUtility();
                if (value.Length > utility.MAX_NCHAR_LENGTH)
                {
                    value = value.Substring(0, utility.MAX_NVARCHAR_LENGTH);
                }
            }

            // Set the size of the parameter to twice the length of the string because each
            // Unicode character is 2 bytes long.
            return AddParameter(name, value, DbType.String, typeof(OracleParameter), direction, length * 2);
        }