Wildcards in output sequential file...

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
kaps
Participant
Posts: 452
Joined: Tue May 10, 2005 12:36 pm

Wildcards in output sequential file...

Post by kaps »

Hi

Can we use wildcards in the file name option of output sequential file stage ?

I tried like this in file name

/path/myfile*.txt

It gives me error code as status = -1. I think this means it is not able to open the seq file.

does the wildcards allowed in the file name ?

Thanks for your inputs...
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Re: Wildcards in output sequential file...

Post by chulett »

kaps wrote:does the wildcards allowed in the file name ?
Nope, not allowed in Input nor Output filenames. Not really sure how you would think that would even work on output... :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
ketfos
Participant
Posts: 562
Joined: Mon May 03, 2004 8:58 pm
Location: san francisco
Contact:

Post by ketfos »

Hi,
i wrote a job exactly as mentioned in the initial message.

It worked fine.

My output file name was defined as

uv/Projects/workfiles/x*.txt

The file was populated correctly. Input was Oracle table.

Ketfos
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Creating files with embedded reserved characters is usually a no-no. These would be chars such as:

Code: Select all

/\&' "!`;,>|
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

What would it mean???

The Sequential File stage uses a C function to write to file. If the file is to be created, what gets created?

If the file doesn't have to be created, does it write to every file whose name matches the wildcard pattern? This is weird.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

ketfos wrote:My output file name was defined as

uv/Projects/workfiles/x*.txt

The file was populated correctly.
It's not about it being 'populated' correctly, it's about the notion of using 'wildcards' in an output filename. Are you expecting it to literally create a two character filename - an 'x' followed by a '*', an asterisk? Or is the expectation that it gets expanded somehow? As noted, an asterisk or splat (or any other metacharacter) is not necessarily allowed as a valid character in a filename.

The question back to kaps is what was the motivation behind the question? Why wondering about using wildcards in the output filename? Unless you just literally want that character in the name, perhaps if you stated what your end result should be, people here could help you figure out how to get there.
-craig

"You can never have too many knives" -- Logan Nine Fingers
kaps
Participant
Posts: 452
Joined: Tue May 10, 2005 12:36 pm

Post by kaps »

Thanks for all the inputs. I think I misstated what I wanted to say...
It's a input sequential file stage not output.

I was wondering If I can read more than one file using seq file stage in a single datastage job.I don't want to use folder stage or don't want to merge the files before reading them using cat commands etc...

Based on the replies here I think wildcards are not supported on seq file stage.

Sorry about the confusion and thanks for the inputs.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

kaps wrote:I was wondering If I can read more than one file using seq file stage in a single datastage job.I don't want to use folder stage or don't want to merge the files before reading them using cat commands etc...
Well, you've eliminated the two most common ways of doing that. :wink:

As, as you've surmised, wildcards are not support in the Sequential File stage.
-craig

"You can never have too many knives" -- Logan Nine Fingers
kaps
Participant
Posts: 452
Joined: Tue May 10, 2005 12:36 pm

Post by kaps »

wow...what a quick reply. Thanks for the lightning reply and that too during 10.30 PM central time and I believe it's 9.30 for you...
This is the greatness of this forum...Hats of to you guys...
rleishman
Premium Member
Premium Member
Posts: 252
Joined: Mon Sep 19, 2005 10:28 pm
Location: Melbourne, Australia
Contact:

Post by rleishman »

Technically, if you didn't care about elegant coding, and you hated the support guys, and they hated you, you could:

- Put /dev/null in the File Name
- Put cat /path/*.txt in the Filter Command
Ross Leishman
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Ross, curious... have you actually tried that and had it work? I assumed it would way back when, but was unable to actually make it work in my 7.0.1 version. Had to fall back to the 'cat them all together before job' approach. :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
rleishman
Premium Member
Premium Member
Posts: 252
Joined: Mon Sep 19, 2005 10:28 pm
Location: Melbourne, Australia
Contact:

Post by rleishman »

It worked a lot better in my head. Is it my fault DataStage can't keep up?

It seems that DS somehow switches globbing off !?! Even if you try to expand a * in a shell script it doesn't expand.

So, if DS can't/won't glob, get someone else to do it for you; like my old friend Perl.

Sequential File Stage:
- Set filters on
- Filename = /dev/null
- Filter command = ....

Code: Select all

perl -pe 'BEGIN{@ARGV=</path/*.txt>}'
Now this solution is even harder to understand than my orininal one; but I tested this one. At least the other one only had a 'cat' - until nit-pickety Craig got hold of it. :wink:

If anyone uses it, please do 2 things:
1. Add a comment/description to the Seq File stage saying what it does.
2. Don't mention my name, or where you got the code.
Ross Leishman
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Excellent! Have to keep this 'work around' in mind for next time. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply