Page 1 of 1

How to pass column name instead of value?

Posted: Thu Dec 07, 2006 7:41 pm
by chalasaniamith
Hi All,
Is there any way to pass the column name instead of the vlaues comming in I dont need the values i just need the column name to pass.
Ex:
seq file -> tx -> seqfile
i want to pass 1st columnname from seqfile to transformer instead of value.

Posted: Thu Dec 07, 2006 7:47 pm
by thebird
Do you mean pass the column name from the table definiton of the source file? Can you be more specific....

Posted: Thu Dec 07, 2006 7:50 pm
by chalasaniamith
yes thats true i want to pass the column name from table definition..

Posted: Thu Dec 07, 2006 7:55 pm
by thebird
chalasaniamith wrote:yes thats true i want to pass the column name from table definition..
Is the table definiton for the file saved in the repository? In which case why dont you hardcode the column name in a Column generator and generate an additional column before sending it to the transformer?

Since your requirement - why you need this column name - is not clear, it would be difficult to give you an optimal solution.

Posted: Thu Dec 07, 2006 7:56 pm
by ray.wurlod
Not possible.

You could create some logic to read it from the schema file, if you are using a schema file to describe the structure of data in the source text file. But there is no mechanism for passing metadata when DataStage expects that you are passing data.

After all, the column name is a property of the link; it should already be there in the Transformer stage.

Posted: Thu Dec 07, 2006 7:58 pm
by chalasaniamith
bcoz you want pass rest of values in the file except for one column i need to pass the column name.so i dont think it will work.

Posted: Thu Dec 07, 2006 8:05 pm
by thebird
chalasaniamith wrote:bcoz you want pass rest of values in the file except for one column i need to pass the column name.so i dont think it will work.
Yeah, then I guess you will have to work as Ray has hinted...

Posted: Thu Dec 07, 2006 9:49 pm
by thebird
bcoz you want pass rest of values in the file except for one column i need to pass the column name.


Since your source is a single file, why not use a UNIX command (perhaps CUT) in an External Source stage to read everything except for the First column and then pass downstream. You can make this ommit any of your fields from being passed to the next stage.

Aneesh

Posted: Fri Dec 08, 2006 3:15 am
by aakashahuja
Or to add to the above mentioned solutions, you can get the column names from the database catalogue tables and pass them downstream just like any other data. Later another operation (like the one suggested by thebird) could be used to pass down the required set of data which you can later merge with what you had received earlier.

Posted: Fri Dec 08, 2006 4:12 pm
by ray.wurlod
Except that sequential files don't have "catalogue tables".
:oops:

Re: How to pass column name instead of value?

Posted: Sat Dec 09, 2006 1:45 pm
by jgreve
chalasaniamith wrote:Hi All,
Is there any way to pass the column name instead of the vlaues comming in I dont need the values i just need the column name to pass.
Ex:
seq file -> tx -> seqfile
i want to pass 1st columnname from seqfile to transformer instead of value.



note: It would help you get better answers if we
knew _why_ you wanted to do this.

If I had to do what you're describing, I would
try to talk my clients out of it.

Failing that, how does this sound?
I'm assuming that your input file has column-headers in
the first record. If it doesn't, you'll need another
place to get them from.

Make seqfile_in and head read from the same file.
Tell seqfile_in that the file contains header-info.
Tell head the file DOES NOT contain header info (oh
yeah - also tell head to load only 1 record).
Kinda like this:

Code: Select all

  seqfile_in --> lookup --> tx --> seqfile_out
                  /|\
                   |
   head------------+
If you need to "lookup" different column names, then
maybe splitting your cols-to-rows and loading the lookup
info from that would work.

Anyway, good luck.
John G.

Re: How to pass column name instead of value?

Posted: Tue Dec 26, 2006 9:49 pm
by chalasaniamith
thanks its worked arround..