Page 1 of 1

Schema File usage

Posted: Mon Jan 25, 2010 11:50 am
by dodda
Hello

I have a requirement where i need to read the first record of the input File and parse each and every field and need to map to the target.target being database.The file is semicoln demilited and and every field is enclosed in quotes. This job we are planning to make as common job so even other datastage jobs can use this as a first job.
the problem is our first record can have variable no of fields
since this is a common job we are going to recieve files with different layouts for the first record in the input file.

i.e File1 can have 6 fields in the input file
File2 can have 9 fields in the input file

just wondering how to make this job as common even if the file layout vhanges for the first record of the input file.

I have tried by creating a schema file and enabling runtime col propagation. but since the no of fields are dynamic (just wondering how to create a schema file.

Posted: Mon Jan 25, 2010 3:47 pm
by ray.wurlod
You need a separate (or at least a suitable) schema file for each source data file. The schema file name and the data file name can both be job parameters.

Posted: Mon Jan 25, 2010 6:22 pm
by dodda
hello ray

thanks for the reply. but how can i make the job common. if i use file 1 and corresponding schema file then i need to map 6 fields to the target and if i use file 2 and the corresponding schema file then i need to map 9 fields.

can this be achieved. i tried this option but didnt work.

Thanks

Posted: Mon Jan 25, 2010 7:31 pm
by ray.wurlod
Be more specific about what you meant by "didn't work". What came through? Was RCP enabled throughout the whole job?

Posted: Mon Jan 25, 2010 10:46 pm
by dodda
yes it was enabled through out the job.

i used the file1 and corresponding schema file in the seqentual file stage.

and in the transfomer on the target side i created 6 output columns which have same col names as in the schema file abd when i run the job it works fine.

but when i use the same file 1 and corresponding schema file in the seq file stage and when i defined 9 output cols on the target side of transformer it throws an error saying col7 is missing.

since i wanted to make this common job i was wondering how to achiveve dynamic mapping based on the schema file.

Thanks

Posted: Tue Jan 26, 2010 5:19 am
by ray.wurlod
What if you define no columns on the output side of the Transformer stage?