View previous topic :: View next topic
|
Author |
Message |
sudhee_rb
New User
Joined: 29 Mar 2006 Posts: 34
|
|
|
|
In my program one of variable definition I need to from 3 byte char to 3 byte decimal.
I changed x(3) to 9(3)v.
Is this is correct, how can I validate this decimal no.
If num_office is numeric
-------------
else
do something.
----
Sudheer |
|
Back to top |
|
|
kgumraj2
New User
Joined: 01 Aug 2007 Posts: 42 Location: Hyderabad
|
|
|
|
Hi,
you are partially correct, but what you what to check do in ----- ?
is it only nuemric check or any other things related, do let us know, thanks |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
Quote: |
i changed x(3) to 9(3)v. |
why 9(03)v here?
If there is a possiibility of getting non numeric char in your x(03) var, then simple move may give you incorrect results.
Try using function NUMVAL. |
|
Back to top |
|
|
sudhee_rb
New User
Joined: 29 Mar 2006 Posts: 34
|
|
|
|
Hi kiran/Abhijit,
Thanks for clarification.
Actually wt happened is, I want to get that value from DB2Table,it is defined as DECIMAL(3,0)(earlier it was CHAR 3) .According to this i need to change in my DB2-COBOL program.
It was validated using this
If num_office is numeric
-------------
else
do something.
----
Shall i use same for validation.
Abhijit-
All values are numbers only(length also 3 digits only).
can u please explain more detail about the function NUMVAL .
Thanks in Advance.
Sudheer |
|
Back to top |
|
|
shankar.v
Active User
Joined: 25 Jun 2007 Posts: 196 Location: Bangalore
|
|
|
|
Code: |
DECIMAL(3,0) IS EQUIVALENT TO PIC S9(3)V USAGE COMP-3. |
|
|
Back to top |
|
|
shankar.v
Active User
Joined: 25 Jun 2007 Posts: 196 Location: Bangalore
|
|
|
|
Quote: |
Actually wt happened is, I want to get that value from DB2Table,it is defined as DECIMAL(3,0)(earlier it was CHAR 3) .According to this i need to change in my DB2-COBOL program. |
DECIMAL(X,Y) datatype columns not allowed any other values other than numeric. So i think no need to check for whether the value contains numeric or not, as you are going to retrieve the value from DB2 table for the DECIMAL(X,Y) datatype column which always contains the numeric values. |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
Quote: |
Abhijit-
All values are numbers only(length also 3 digits only).
can u please explain more detail about the function NUMVAL . |
Function numval details |
|
Back to top |
|
|
saptagiri kintali
New User
Joined: 21 Sep 2007 Posts: 20 Location: chennai
|
|
|
|
another thing when it is of 9(3) means , u cant check with IS NUMERIC ,it will lead to an error. |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
saptagiri kintali wrote: |
another thing when it is of 9(3) means , u cant check with IS NUMERIC ,it will lead to an error. |
Maybe in the olden days, but the Fine Manual now states that the dataname can/must be "DISPLAY, NATIONAL, COMPUTATIONAL-3, or PACKED-DECIMAL when NUMERIC is specified".... |
|
Back to top |
|
|
|