1

What should be my DML for input file which has data like 1,2,34,43,66

The problem which i am facing when i put the below DML

record decimal(",") val; end;

is that the last number is not getting read properly.

Is there any way to read this by only using Input file component.

Zam
  • 2,880
  • 1
  • 18
  • 33
Yash Sinha
  • 11
  • 1
  • 2
  • Welcome to Stack Overflow! Please read [what this site is about](https://stackoverflow.com/about) and "[How to ask](https://stackoverflow.com/questions/how-to-ask)" before asking a question. – tobsob Dec 11 '19 at 06:48

3 Answers3

0

you have described only ONE numeric field, but you have 5 fields

"new line" (new record) also should be described

are you using BRE ? you could create DML in BRE

Zam
  • 2,880
  • 1
  • 18
  • 33
0

You can try the following DML I guess it should work:

record
decimal(",") val1;
decimal(",") val2;
decimal(",") val3;
decimal(",") val4;
decimal(",") val5;
string("\n") newline = NULL;
end
0

I presume you want to read each number as a record. The problem is: data is not compatible with your desire, last number is not delimited by a ",".

If you can't change the data, you could read all the input in a single record, using:

record
 string("\n") val;
end

then use a normalize component to split the record:

out :: length(in) =
begin
  out :: length_of(string_split(in.val, ","));
end;

out :: normalize(in, index) =
begin
   let string(";")[5] my_vec;
   my_vec =  string_split(in.val, ",");
   out.val :: decimal_lpad( my_vec[index], 5 );
end;

(there are probably better solutions, I am still not an expert, but there wasn't an answer yet)

momobo
  • 1,755
  • 1
  • 14
  • 19