Thread: CHAR scalar function
02-15-07, 14:34 #1Registered User
- Join Date
- Feb 2007
Unanswered: CHAR scalar function
What are the rules when you do a CHAR(decimal-field).
I'm sorry to say read the manual, but did not understand it. I've pasted the manual below
Decimal to Character
An expression that returns a value that is a built-in decimal data type. To specify a different precision and scale for the expression's value, apply the DECIMAL function before applying the CHAR function.
Specifies the single-byte character constant (CHAR or VARCHAR) that is used to delimit the decimal digits in the result character string. The character must not be a digit, a plus sign (+), a minus sign (-), or a blank. The default is the period (.) or comma (,). For information on what factors govern the choice, see "Decimal point representation" in topic 2.24.2.
The result is the fixed-length character string representation of the argument in the form of an SQL decimal constant. The result includes a decimal-character and p digits, where p is the precision of the decimal-expression. If the argument is negative, the first character of the result is a minus sign. Otherwise, the first character is a blank, which means that a positive value always has one leading blank.
The leading blank is not returned for CAST(decimal-expression AS CHAR(n)).
The length of the result is 2+p, where p is the precision of the decimal-expression.
02-16-07, 03:40 #2Registered User
- Join Date
- May 2003
Basically, if you have the following SQL statement, then the salary field will be returned as a character field:
select char(salary) from emp
Note that salary is defined as DECIMAL (9,2) in the table.
If you explain what you are trying to do, then someone can suggest the appropriate function or syntax to use.M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390