473,657 Members | 2,473 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 9102
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.do c/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.do c/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:
>MeBuggyYouJa ne 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
fundamentall y 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.d oc/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.co mwrote:
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.do c/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.co mwrote:
>MeBuggyYouJa ne wrote:
>>Dave Hughes wrote:
MeBuggyYouJa ne 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
fundamentall y 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
represente d 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
8005
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 the domain server address. (these changes were in the $recipient and $referers section) I have set up the form and can get the form to email me the results. I have two main problems. The first one is that I am trying to get the form to go to a...
3
6536
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 to have apache use a file not within it's own home directory, so I was going to have a .py file in cgi-bin forward the user on to the correct error page.
4
1329
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 the file is then saved by the user to their hard disk
1
2271
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 name="attribute"/> <xsl:param name="error_msg"/> <xsl:message terminate="no">
4
11425
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 XMLHTTP object. However, when the page requested through the XML object makes a <%Response.Redirect()%> call, a new session is created each time. Is this a flaw in the XMLHTTP Object? How can I force the session to remain the same after a...
2
3132
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 html files although php files can be included. I have a page that detects the language used on the users browser: <? class object {}; $config = new object; $config->dir = "/home/path/public_html/language2/lang_sets/"; if (! isset($lang)) {...
7
4610
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 passing on the original form data there instead. Below is a simplified version of what i'm trying to do. The user sumits a word. If it's in the DB then the word is listed below the reset form. What i need is to redirect to a new page "newword.php" if...
18
2661
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: is supposed to take a fully qualified URL.
1
7280
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 and Brand I need to make some changes on a a number of brands in a Category
0
8397
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8310
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8827
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8503
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6167
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4158
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2731
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1620
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.