Hello, On Tue, 21 Nov 2006, fbocch2595@xxxxxxx wrote:
Is there a default file name?
Hmmm... I'm not exactly sure what you mean by that. Let's review the code again, and maybe that'll answer your question.
Here's the original code (this is a QShell commnd) that was posted: db2 "select agtbra || ',' || char(agtnoa) || ',' || agtnaa from anvdev.agtmas" | sed -n '/,/p' > /mxp/mxpsql.csvThis command line runs the "db2" program. It passes it a parameter containing an SQL statement. At this point in the process, the SQL statement is just string that will be passed as a parameter to the DB2 program. Here's the parameter it's passing:
"select wgtbra || ',' || char(agtnoa) || ',' || agtnaa from anvdev.agtmas"The DB2 program takes that parameter and executes it as an SQL statement, and generates a report from the result. It writes that report to the program's "stdout" stream.
This SQL statement explicitly lists the filename as "anvdev.agtmas" (this is SQL naming convention. It's equivalent to ANVDEV/AGTMAS in our more fmailiar naming convention)
By default, the "stdout" of the db2 program would be printed on the screen. So I guess you could call that a "default" filename. But in this example, it's not. Instead, it's being redirected to become the input of the 'sed' command. That's what the pipe operator does, it redirects the output from one program to the input of another program.
In this case, you have this: db2 (parms) | sed (parms)So the output of the db2 program is redirected to the input of the sed program. By default, sed reads it's input from the 'stdin' data stream. If you don't direct the input from another program or file, it will default to receiving input from the keyboard. But in this case, it's input is coming from the output of the db2 command.
Sed then prints out any lines that contain a comma. Thus, it effectively "filters" out any non-comma lines. It writes the result to it's own stdout stream
Again, this standard output would be printed on the screen by default. However, in this case, it's redirected to a file. That's what the > operator does, it redirects standard output to a disk file.
So, once again, removing the parmeters for clarity, the statement looks like this:
db2 (parms) | sed (parms) > /mxp/mxpsql.csvThe db2 program runs the SQL statement listed in it's parameter. It writes the output to the sed program. The sed program filters out all non-comma lines and writes the output to the /xmp/mxpsql.csv stream file in the IFS.
Does that answer your question?
amazon.com ads help fund midrange.com operations