convert char to integer
Moderators: chulett, rschirm, roy
convert char to integer
Hi All,
I have a source flat file with one of the column srccol1 char3 and my corresponding column in the database is trgcol1 num3.
If you look at the above description the souce column datatype is char and the target column is number.
Should I need to convert the char to num to populate to table? or will Datastage internally converts the char to num?
If doesn't convert the how I need to convert?
Please suggest me
Thanks in advance
Regards,
Saik.
I have a source flat file with one of the column srccol1 char3 and my corresponding column in the database is trgcol1 num3.
If you look at the above description the souce column datatype is char and the target column is number.
Should I need to convert the char to num to populate to table? or will Datastage internally converts the char to num?
If doesn't convert the how I need to convert?
Please suggest me
Thanks in advance
Regards,
Saik.
Re: convert char to integer
Datastage will not convert char to num. You need to convert char to num using Int() Function.rafidwh wrote:Hi All,
I have a source flat file with one of the column srccol1 char3 and my corresponding column in the database is trgcol1 num3.
If you look at the above description the souce column datatype is char and the target column is number.
Should I need to convert the char to num to populate to table? or will Datastage internally converts the char to num?
If doesn't convert the how I need to convert?
Please suggest me
Thanks in advance
Regards,
Saik.
Last edited by balajisr on Mon Jun 12, 2006 2:21 am, edited 1 time in total.
Indeed. Int() returns integer portion from the number value.rafidwh wrote:But from the help,I found that the int() function is returning the integer portion from the number value like srccol value is 2.3 ,if we use Int it returns as 2,
Now will Int() aslo converts char to integer
I think i got it totally wrong. For checking whether the string contains only numeric value do not use Alpha() function use Num() function which checks whether the string is numeric.
As for conversion i am not sure that Int() is the right method to use for converting char to integer. Sorry for my mistake.
DataStage will perform an implicit conversion from a string to a number and vice-versa.
Code: Select all
x = '123'
x = x : '4'
x = x * 2
x = x[3,2]
If your CHARacter field contains only digits then you do not need to perform any explicit conversions, see the example I gave in the previous post.
If your CHAR fields contains mixed numeric and text then you will need to provide some conversion code to make sure that DataStage interprets this field correctly. There are ICONV() conversions such as "MCN" that you can use to effect this.
If your CHAR fields contains mixed numeric and text then you will need to provide some conversion code to make sure that DataStage interprets this field correctly. There are ICONV() conversions such as "MCN" that you can use to effect this.
Rafidwh - did you actually read my post? Please look into your BASIC programming PDF file and search for the MCN conversion and that will answer your question on what can technically be done with alphabetic characters in a numeric string. Nobody here can answer what needs to be done according to your business rules.
Hi All,
I have the similar question, I have data which is signed decimal value from source flat file. This field will have -/+ like ' -213.23004'. We need to keep the sign on the target (oracle number). How to do this using DS.
Note: We are using DS 7.5
Please some one help me.
Thanks in advance
-NB
I have the similar question, I have data which is signed decimal value from source flat file. This field will have -/+ like ' -213.23004'. We need to keep the sign on the target (oracle number). How to do this using DS.
Note: We are using DS 7.5
Please some one help me.
Thanks in advance
-NB