Question on file loading to table

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
puliram
Participant
Posts: 20
Joined: Mon Apr 28, 2008 6:10 pm

Question on file loading to table

Post by puliram »

Hi,
I have a csv file reading using SeqFile stage. I have about 10 columns in csv file(eg. below) but the last two columns are decimals.

Here is Eg. my csv file
641,ABC,2009,10,ABCDEF,GHIJKLM,111,200,485262.93,336360.00

first 8 files are varchar files and last two are decimal fields i would like to read
but till the 9 field i was successful but 10 column, i couldnt able to read as decimal but could able to read it as varchar

Any idea, how I can read 10th column too as decimal.

Thanks
gssr
Participant
Posts: 243
Joined: Fri Jan 09, 2009 12:51 am
Location: India

Post by gssr »

As you read the column as Varchar, you can convert it using the Type conversion technique. Do you get the whole value as Varchar(Including the decimal value)?
RAJ
puliram
Participant
Posts: 20
Joined: Mon Apr 28, 2008 6:10 pm

Post by puliram »

gssr wrote:As you read the column as Varchar, you can convert it using the Type conversion technique. Do you get the whole value as Varchar(Including the decimal value)?
I can use the type coversion but its not working. all 0's are being loaded into table in last column

Just let me know the format of stringtodecimal syntax, though its is clear in help, its not helping much.
gssr
Participant
Posts: 243
Joined: Fri Jan 09, 2009 12:51 am
Location: India

Post by gssr »

Can you able to see the records in the sequential file ?. If not then check with the metadata you have mentioned and then we can go for the type conversion!!
RAJ
gssr
Participant
Posts: 243
Joined: Fri Jan 09, 2009 12:51 am
Location: India

Post by gssr »

puliram wrote: Just let me know the format of stringtodecimal syntax, though its is clear in help, its not helping much.
Can you post the conversion syntax that you have used? :?:

Actually,In 7x, we dont need any conversion function,as this can be done in the implicit conversion.
RAJ
puliram
Participant
Posts: 20
Joined: Mon Apr 28, 2008 6:10 pm

Post by puliram »

gssr wrote:Can you able to see the records in the sequential file ?. If not then check with the metadata you have mentioned and then we can go for the type conversion!!
Yes I can able to see records in veiwdata, with final column as varchar. But want to read as decimal.
I have another file, with two decimals which is at 7,8th positions, I was able to read as decimals and loaded successfully.
Only if the decimal column is at the end, there might be some rule to read as decimal. Just need that help
puliram
Participant
Posts: 20
Joined: Mon Apr 28, 2008 6:10 pm

Post by puliram »

gssr wrote:As you read the column as Varchar, you can convert it using the Type conversion technique. Do you get the whole value as Varchar(Including the decimal value)?
yes got whole value as varchar including decimal, but dont want that. want to read as decimal
gssr
Participant
Posts: 243
Joined: Fri Jan 09, 2009 12:51 am
Location: India

Post by gssr »

Then try to map the Varchar Column to Decimal without using any function to the target file. For your records your varchar(9) should be mapped to Decimal(6,2)

I do had a situation like you, and used the above solution which worked fine! (In 7x) :roll: :!:
RAJ
puliram
Participant
Posts: 20
Joined: Mon Apr 28, 2008 6:10 pm

Post by puliram »

gssr wrote:Then try to map the Varchar Column to Decimal without using any function to the target file. For your records your varchar(9) should be mapped to Decimal(6,2)

I do had a situation like you, and used the above solution which worked fine! (In 7x) :roll: :!:
TRIED, but did not worked, still loading as zero's into table.
puliram
Participant
Posts: 20
Joined: Mon Apr 28, 2008 6:10 pm

Post by puliram »

puliram wrote:
gssr wrote:Then try to map the Varchar Column to Decimal without using any function to the target file. For your records your varchar(9) should be mapped to Decimal(6,2)

I do had a situation like you, and used the above solution which worked fine! (In 7x) :roll: :!:
TRIED, but did not worked, still loading as zero's into table.
Resolved, tried myself

read as float
and then used function
DFloatToDecimal, it worked

Thanks
Post Reply