473,394 Members | 1,226 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Redirect SELECT results to a file

This should be simple, and the docs say so, but no...

1) I have an .hta file (VBScript), with a call to windoze shell
2) the shell call is to db2cmd, input from a file
3) the command file has a db2 SELECT <blah command

If I insert foo.txt in the db2cmd command line, the
commands, result set, and messages go to foo.txt. That's sort
of OK, except that running EXPORT, i can concoct the command
with a file for output, and the result goes there. The client
wants both the SELECT and EXPORT to work the same: result
set in a file.

The docs say that I can insert -r foo.txt in either the
db2cmd command line or the db2 command line, and get the
result of the SELECT in foo.txt. Nope. Windoze creates foo.txt,
but db2 errors with "unable to access file".

I don't think it should be so difficult. Nothing at the DB2 site
that I could find explains why this doesn't work.

winXP/SP2, UDB v8.2.9
Jul 8 '08 #1
5 9080
MeBuggyYouJane wrote:
This should be simple, and the docs say so, but no...

1) I have an .hta file (VBScript), with a call to windoze shell
2) the shell call is to db2cmd, input from a file
3) the command file has a db2 SELECT <blah command

If I insert foo.txt in the db2cmd command line, the
commands, result set, and messages go to foo.txt. That's sort
of OK, except that running EXPORT, i can concoct the command
with a file for output, and the result goes there. The client
wants both the SELECT and EXPORT to work the same: result
set in a file.
A quick word of caution regarding this: EXPORT's output is
fundamentally different (in purpose) to the captured output of a SELECT
statement executed by the CLP (e.g. via -r or a stdout redirection):

EXPORT is meant for data transfer, pure and simple. So, EXPORT outputs
data unambiguously in specifically structured formats (IXF, delimited,
fixed width).

In contrast, the CLP's output is meant for human consumption - /not/
for data transfer. Hence the CLP takes certain liberties in its output.
Columns are truncated at 8kb (e.g. CLOB or big VARCHARs), NULLs are
represented by a "-" (which can't be distinguished from a CHAR column
containing a "-"), dates are formatted into the client's locale, etc.
etc.

So - nothing wrong with wanting them to work similarly, but I'd be very
wary of somebody wanting to use them for the same purpose. Anyway...
The docs say that I can insert -r foo.txt in either the
db2cmd command line or the db2 command line, and get the
result of the SELECT in foo.txt. Nope. Windoze creates foo.txt,
but db2 errors with "unable to access file".
-r is an option for db2, not db2cmd. db2cmd is simply a shell used on
Windows to provide the necessary environment for db2. The only options
it takes are -i, -w, -c, and -t [1]. I tried out -r on both Linux and
Windows sessions and it seemed to work fine (no mysterious access
errors).

I've no idea why DB2 would say it can't access the file when it's been
created successfully, unless the file already existed and the user
executing the CLP doesn't have the necessary privileges to overwrite
the file.
I don't think it should be so difficult.
That's because it's not ;-). I suspect there may be a problem with the
command line you're using, or the way you're invoking the CLP. Can you
post the /exact/ command line you're using, along with the output? If
you're launching the CLP from an application the code for launching the
CLP would be good too.

[1]
http://publib.boulder.ibm.com/infoce.../com.ibm.db2.l
uw.admin.cmd.doc/doc/r0002036.html
Cheers,

Dave.
Jul 8 '08 #2
Dave Hughes wrote:
MeBuggyYouJane wrote:
>This should be simple, and the docs say so, but no...

1) I have an .hta file (VBScript), with a call to windoze shell
2) the shell call is to db2cmd, input from a file
3) the command file has a db2 SELECT <blah command

If I insert foo.txt in the db2cmd command line, the
commands, result set, and messages go to foo.txt. That's sort
of OK, except that running EXPORT, i can concoct the command
with a file for output, and the result goes there. The client
wants both the SELECT and EXPORT to work the same: result
set in a file.

A quick word of caution regarding this: EXPORT's output is
fundamentally different (in purpose) to the captured output of a SELECT
statement executed by the CLP (e.g. via -r or a stdout redirection):

EXPORT is meant for data transfer, pure and simple. So, EXPORT outputs
data unambiguously in specifically structured formats (IXF, delimited,
fixed width).

In contrast, the CLP's output is meant for human consumption - /not/
for data transfer. Hence the CLP takes certain liberties in its output.
Columns are truncated at 8kb (e.g. CLOB or big VARCHARs), NULLs are
represented by a "-" (which can't be distinguished from a CHAR column
containing a "-"), dates are formatted into the client's locale, etc.
etc.

So - nothing wrong with wanting them to work similarly, but I'd be very
wary of somebody wanting to use them for the same purpose. Anyway...
>The docs say that I can insert -r foo.txt in either the
db2cmd command line or the db2 command line, and get the
result of the SELECT in foo.txt. Nope. Windoze creates foo.txt,
but db2 errors with "unable to access file".

-r is an option for db2, not db2cmd. db2cmd is simply a shell used on
Windows to provide the necessary environment for db2. The only options
it takes are -i, -w, -c, and -t [1]. I tried out -r on both Linux and
Windows sessions and it seemed to work fine (no mysterious access
errors).

I've no idea why DB2 would say it can't access the file when it's been
created successfully, unless the file already existed and the user
executing the CLP doesn't have the necessary privileges to overwrite
the file.
>I don't think it should be so difficult.

That's because it's not ;-). I suspect there may be a problem with the
command line you're using, or the way you're invoking the CLP. Can you
post the /exact/ command line you're using, along with the output? If
you're launching the CLP from an application the code for launching the
CLP would be good too.

[1]
http://publib.boulder.ibm.com/infoce.../com.ibm.db2.l
uw.admin.cmd.doc/doc/r0002036.html
Cheers,

Dave.
Yes, they're different. The client just doesn't want/need the commands
and messages. Makes sense. And the error code flashed by before I
caught it: DB21005E. But that just translates to can't use the file.

No Google Groups or usenet in cubeland, so it'll have to be on the
morrow. I did find an APAR for that code, but not quite the same symptom.

thanks.
Jul 9 '08 #3
MeBuggyYouJane wrote:
Dave Hughes wrote:
>MeBuggyYouJane wrote:
>>This should be simple, and the docs say so, but no...

1) I have an .hta file (VBScript), with a call to windoze shell
2) the shell call is to db2cmd, input from a file
3) the command file has a db2 SELECT <blah command

If I insert foo.txt in the db2cmd command line, the
commands, result set, and messages go to foo.txt. That's sort
of OK, except that running EXPORT, i can concoct the command
with a file for output, and the result goes there. The client
wants both the SELECT and EXPORT to work the same: result
set in a file.

A quick word of caution regarding this: EXPORT's output is
fundamentally different (in purpose) to the captured output of a SELECT
statement executed by the CLP (e.g. via -r or a stdout redirection):

EXPORT is meant for data transfer, pure and simple. So, EXPORT outputs
data unambiguously in specifically structured formats (IXF, delimited,
fixed width).

In contrast, the CLP's output is meant for human consumption - /not/
for data transfer. Hence the CLP takes certain liberties in its output.
Columns are truncated at 8kb (e.g. CLOB or big VARCHARs), NULLs are
represented by a "-" (which can't be distinguished from a CHAR column
containing a "-"), dates are formatted into the client's locale, etc.
etc.

So - nothing wrong with wanting them to work similarly, but I'd be very
wary of somebody wanting to use them for the same purpose. Anyway...
>>The docs say that I can insert -r foo.txt in either the
db2cmd command line or the db2 command line, and get the
result of the SELECT in foo.txt. Nope. Windoze creates foo.txt,
but db2 errors with "unable to access file".

-r is an option for db2, not db2cmd. db2cmd is simply a shell used on
Windows to provide the necessary environment for db2. The only options
it takes are -i, -w, -c, and -t [1]. I tried out -r on both Linux and
Windows sessions and it seemed to work fine (no mysterious access
errors).

I've no idea why DB2 would say it can't access the file when it's been
created successfully, unless the file already existed and the user
executing the CLP doesn't have the necessary privileges to overwrite
the file.
>>I don't think it should be so difficult.

That's because it's not ;-). I suspect there may be a problem with the
command line you're using, or the way you're invoking the CLP. Can you
post the /exact/ command line you're using, along with the output? If
you're launching the CLP from an application the code for launching the
CLP would be good too.

[1]
http://publib.boulder.ibm.com/infoce.../com.ibm.db2.l
uw.admin.cmd.doc/doc/r0002036.html
Cheers,

Dave.

Yes, they're different. The client just doesn't want/need the commands
and messages. Makes sense. And the error code flashed by before I
caught it: DB21005E. But that just translates to can't use the file.

No Google Groups or usenet in cubeland, so it'll have to be on the
morrow. I did find an APAR for that code, but not quite the same symptom.

thanks.
Turns out to be from either WshShell or windoze itself. I was able to
get the syntax to work from db2cmd directly. Didn't, and can't, see why
it should be different from the shell. But from the shell it will only
write to a directory local file. Better than nothing. oh well.

thanks.
Jul 10 '08 #4
On Jul 10, 2:33 am, MeBuggyYouJane <gnuo...@rcn.comwrote:
MeBuggyYouJane wrote:
Dave Hughes wrote:
MeBuggyYouJane wrote:
>This should be simple, and the docs say so, but no...
>1) I have an .hta file (VBScript), with a call to windoze shell
2) the shell call is to db2cmd, input from a file
3) the command file has a db2 SELECT <blah command
>If I insert foo.txt in the db2cmd command line, the
commands, result set, and messages go to foo.txt. That's sort
of OK, except that running EXPORT, i can concoct the command
with a file for output, and the result goes there. The client
wants both the SELECT and EXPORT to work the same: result
set in a file.
A quick word of caution regarding this: EXPORT's output is
fundamentally different (in purpose) to the captured output of a SELECT
statement executed by the CLP (e.g. via -r or a stdout redirection):
EXPORT is meant for data transfer, pure and simple. So, EXPORT outputs
data unambiguously in specifically structured formats (IXF, delimited,
fixed width).
In contrast, the CLP's output is meant for human consumption - /not/
for data transfer. Hence the CLP takes certain liberties in its output.
Columns are truncated at 8kb (e.g. CLOB or big VARCHARs), NULLs are
represented by a "-" (which can't be distinguished from a CHAR column
containing a "-"), dates are formatted into the client's locale, etc.
etc.
So - nothing wrong with wanting them to work similarly, but I'd be very
wary of somebody wanting to use them for the same purpose. Anyway...
>The docs say that I can insert -r foo.txt in either the
db2cmd command line or the db2 command line, and get the
result of the SELECT in foo.txt. Nope. Windoze creates foo.txt,
but db2 errors with "unable to access file".
-r is an option for db2, not db2cmd. db2cmd is simply a shell used on
Windows to provide the necessary environment for db2. The only options
it takes are -i, -w, -c, and -t [1]. I tried out -r on both Linux and
Windows sessions and it seemed to work fine (no mysterious access
errors).
I've no idea why DB2 would say it can't access the file when it's been
created successfully, unless the file already existed and the user
executing the CLP doesn't have the necessary privileges to overwrite
the file.
>I don't think it should be so difficult.
That's because it's not ;-). I suspect there may be a problem with the
command line you're using, or the way you're invoking the CLP. Can you
post the /exact/ command line you're using, along with the output? If
you're launching the CLP from an application the code for launching the
CLP would be good too.
[1]
http://publib.boulder.ibm.com/infoce.../com.ibm.db2.l
uw.admin.cmd.doc/doc/r0002036.html
Cheers,
Dave.
Yes, they're different. The client just doesn't want/need the commands
and messages. Makes sense. And the error code flashed by before I
caught it: DB21005E. But that just translates to can't use the file.
No Google Groups or usenet in cubeland, so it'll have to be on the
morrow. I did find an APAR for that code, but not quite the same symptom.
thanks.

Turns out to be from either WshShell or windoze itself. I was able to
get the syntax to work from db2cmd directly. Didn't, and can't, see why
it should be different from the shell. But from the shell it will only
write to a directory local file. Better than nothing. oh well.
Just a thought, did you use an absolute or relative path? Also, is it
a local disk, or is it mounted somehow?
/Lennart

Jul 10 '08 #5
Lennart wrote:
On Jul 10, 2:33 am, MeBuggyYouJane <gnuo...@rcn.comwrote:
>MeBuggyYouJane wrote:
>>Dave Hughes wrote:
MeBuggyYouJane wrote:
This should be simple, and the docs say so, but no...
1) I have an .hta file (VBScript), with a call to windoze shell
2) the shell call is to db2cmd, input from a file
3) the command file has a db2 SELECT <blah command
If I insert foo.txt in the db2cmd command line, the
commands, result set, and messages go to foo.txt. That's sort
of OK, except that running EXPORT, i can concoct the command
with a file for output, and the result goes there. The client
wants both the SELECT and EXPORT to work the same: result
set in a file.
A quick word of caution regarding this: EXPORT's output is
fundamentally different (in purpose) to the captured output of a SELECT
statement executed by the CLP (e.g. via -r or a stdout redirection):
EXPORT is meant for data transfer, pure and simple. So, EXPORT outputs
data unambiguously in specifically structured formats (IXF, delimited,
fixed width).
In contrast, the CLP's output is meant for human consumption - /not/
for data transfer. Hence the CLP takes certain liberties in its output.
Columns are truncated at 8kb (e.g. CLOB or big VARCHARs), NULLs are
represented by a "-" (which can't be distinguished from a CHAR column
containing a "-"), dates are formatted into the client's locale, etc.
etc.
So - nothing wrong with wanting them to work similarly, but I'd be very
wary of somebody wanting to use them for the same purpose. Anyway...
The docs say that I can insert -r foo.txt in either the
db2cmd command line or the db2 command line, and get the
result of the SELECT in foo.txt. Nope. Windoze creates foo.txt,
but db2 errors with "unable to access file".
-r is an option for db2, not db2cmd. db2cmd is simply a shell used on
Windows to provide the necessary environment for db2. The only options
it takes are -i, -w, -c, and -t [1]. I tried out -r on both Linux and
Windows sessions and it seemed to work fine (no mysterious access
errors).
I've no idea why DB2 would say it can't access the file when it's been
created successfully, unless the file already existed and the user
executing the CLP doesn't have the necessary privileges to overwrite
the file.
I don't think it should be so difficult.
That's because it's not ;-). I suspect there may be a problem with the
command line you're using, or the way you're invoking the CLP. Can you
post the /exact/ command line you're using, along with the output? If
you're launching the CLP from an application the code for launching the
CLP would be good too.
[1]
http://publib.boulder.ibm.com/infoce.../com.ibm.db2.l
uw.admin.cmd.doc/doc/r0002036.html
Cheers,
Dave.
Yes, they're different. The client just doesn't want/need the commands
and messages. Makes sense. And the error code flashed by before I
caught it: DB21005E. But that just translates to can't use the file.
No Google Groups or usenet in cubeland, so it'll have to be on the
morrow. I did find an APAR for that code, but not quite the same symptom.
thanks.
Turns out to be from either WshShell or windoze itself. I was able to
get the syntax to work from db2cmd directly. Didn't, and can't, see why
it should be different from the shell. But from the shell it will only
write to a directory local file. Better than nothing. oh well.

Just a thought, did you use an absolute or relative path? Also, is it
a local disk, or is it mounted somehow?
/Lennart
All local. It's clear that there is some pathological interaction among
DB2/windoze/WshShell. If nothing else, the users and permissions
differ between the local directory and non-local directory file. The
local has DB2ADMNS and DB2USERS defined.

For now, they'll have to live with getting the SELECT listing in the
..hta file's directory.

thanks.
Jul 12 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Damo | last post by:
Could someone please help me. I am a newbie at PHP. I downloaded formail.php Version 5.0 from Jacks scripts( http://www.dtheatre.com/scripts/ )and changed the required areas to my email address and...
3
by: Sean Berry | last post by:
Hi there. I am relativly new to Python CGI and need a question answered. I have made custom 404 error pages and have them in various web directories. I have not been able to figure out a way...
4
by: news.microsoft.com | last post by:
Hello All, im am new to ASP.NET, so bare with me. i have an application that i am building in stages. stage1 user picks data required stage2 file is written to a virutal directory Stage3...
1
by: Petterson Mikael | last post by:
Hi, I am using xalan. In my stylesheet I have the following snippet to write to std out when a specific error occurs. <xsl:template name="class_error"> <xsl:param name="class"/> <xsl:param...
4
by: mike.biang | last post by:
I have an ASP page that is using an XMLHTTP object to request various pages from my server. I keep a single session throughout the XMLHTTP requests by bassing the ASPSESSIONID cookie through the...
2
by: scar5308 | last post by:
I have been struggling with this problem for over a week and am not much nearer a solution. I am trying to create a multi language site that only requires the content to be added as simple text or...
7
bugboy
by: bugboy | last post by:
Hi, I'm just learning PHP. I want to redirect the user, after hitting submit, either to the same page displaying the results (as it is now) or if no results are found then send them to a new page...
18
by: Paul Lautman | last post by:
JRough wrote: What do you mean by "redirect the output to Excel"??? Excel isn't a location, it's a spreadsheet program that some (but not all users) will have on their machine. BTW, Location:...
1
by: gnawz | last post by:
Hi guys, I have a couple of php files that perform various tasks. I will use fields in my system and provide code as well I need help as follows: My database contains the fields Category...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.