dbTalk Databases Forums  

CLP giving weird error code for simple SQL

comp.databases.ibm-db2 comp.databases.ibm-db2


Discuss CLP giving weird error code for simple SQL in the comp.databases.ibm-db2 forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Morch
 
Posts: n/a

Default CLP giving weird error code for simple SQL - 05-20-2010 , 11:03 AM






I'm using the CLP on a Windows XP machine, DB2 ESE 9.5. I connect to
the SAMPLE database and issue the following command :

db2 select * from proj where deptno <> 'E21'

and the response I get is :

Quote:
was unexpected at this time.
If I use the command editor application (GUI thingie) and enter the
same command (minus the "db2") it all works fine.

It seems that the CLP dislikes the <> operator for some reason.

Can anyone elucidate me on this?

Mairhtin

Reply With Quote
  #2  
Old   
The Boss
 
Posts: n/a

Default Re: CLP giving weird error code for simple SQL - 05-20-2010 , 11:14 AM






On May 20, 6:03*pm, Morch <mairh... (AT) gmail (DOT) com> wrote:
Quote:
I'm using the CLP on a Windows XP machine, DB2 ESE 9.5. *I connect to
the SAMPLE database and issue the following command :

db2 select * from proj where deptno <> 'E21'

and the response I get is :

was unexpected at this time.

If I use the command editor application (GUI thingie) and enter the
same command (minus the "db2") it all works fine.

It seems that the CLP dislikes the <> operator for some reason.

Can anyone elucidate me on this?

Mairhtin
In CLP you should 'double quote' your SQL-statements to prevent wrong
interpretations like this by the OS.
Change your statement like this:
db2 "select * from proj where deptno <> E'21'"

HTH

--
Jeroen

Reply With Quote
  #3  
Old   
The Boss
 
Posts: n/a

Default Re: CLP giving weird error code for simple SQL - 05-20-2010 , 11:17 AM



On May 20, 6:14*pm, The Boss <nlt... (AT) baasbovenbaas (DOT) demon.nl> wrote:
Quote:
On May 20, 6:03*pm, Morch <mairh... (AT) gmail (DOT) com> wrote:





I'm using the CLP on a Windows XP machine, DB2 ESE 9.5. *I connect to
the SAMPLE database and issue the following command :

db2 select * from proj where deptno <> 'E21'

and the response I get is :

was unexpected at this time.

If I use the command editor application (GUI thingie) and enter the
same command (minus the "db2") it all works fine.

It seems that the CLP dislikes the <> operator for some reason.

Can anyone elucidate me on this?

Mairhtin

In CLP you should 'double quote' your SQL-statements to prevent wrong
interpretations like this by the OS.
Change your statement like this:
db2 "select * from proj where deptno <> E'21'"

HTH

Sorry for the typo, E'21' should be 'E21' of course.

--
Jeroen

Reply With Quote
  #4  
Old   
Morch
 
Posts: n/a

Default Re: CLP giving weird error code for simple SQL - 05-20-2010 , 01:17 PM



Thanks for that. I tried single quotes around the command, like I
would do in a Unix Shell prompt, and when it failed, I raised my fists
to the heavens and cursed. I didn't try double quotes. Stupid
Windoze.

M


On May 20, 11:17*am, The Boss <nlt... (AT) baasbovenbaas (DOT) demon.nl> wrote:
Quote:
On May 20, 6:14*pm, The Boss <nlt... (AT) baasbovenbaas (DOT) demon.nl> wrote:



On May 20, 6:03*pm, Morch <mairh... (AT) gmail (DOT) com> wrote:

I'm using the CLP on a Windows XP machine, DB2 ESE 9.5. *I connect to
the SAMPLE database and issue the following command :

db2 select * from proj where deptno <> 'E21'

and the response I get is :

was unexpected at this time.

If I use the command editor application (GUI thingie) and enter the
same command (minus the "db2") it all works fine.

It seems that the CLP dislikes the <> operator for some reason.

Can anyone elucidate me on this?

Mairhtin

In CLP you should 'double quote' your SQL-statements to prevent wrong
interpretations like this by the OS.
Change your statement like this:
db2 "select * from proj where deptno <> E'21'"

HTH

Sorry for the typo, E'21' should be 'E21' of course.

--
Jeroen

Reply With Quote
  #5  
Old   
Helmut Tessarek
 
Posts: n/a

Default Re: CLP giving weird error code for simple SQL - 05-20-2010 , 07:07 PM



You have to use double quotes in a UNIX shell as well.

On 20.05.10 14:17 , Morch wrote:
Quote:
Thanks for that. I tried single quotes around the command, like I
would do in a Unix Shell prompt, and when it failed, I raised my fists
to the heavens and cursed. I didn't try double quotes. Stupid
Windoze.

--
Helmut K. C. Tessarek
DB2 Performance and Development

/*
Thou shalt not follow the NULL pointer for chaos and madness
await thee at its end.
*/

Reply With Quote
  #6  
Old   
Lennart Jonsson
 
Posts: n/a

Default Re: CLP giving weird error code for simple SQL - 05-21-2010 , 12:12 AM



On 2010-05-21 02:07, Helmut Tessarek wrote:
Quote:
You have to use double quotes in a UNIX shell as well.
My first reaction as well, but it actually worked with quotes:

[lelle@...]$ db2 'select count(*) from price'

1
-----------
11765

1 record(s) selected.


Quote:
On 20.05.10 14:17 , Morch wrote:
[...]
Stupid Windoze.

Agreed ;-)


/Lennart

Reply With Quote
  #7  
Old   
Helmut Tessarek
 
Posts: n/a

Default Re: CLP giving weird error code for simple SQL - 05-21-2010 , 12:22 AM



Quote:
My first reaction as well, but it actually worked with quotes:

[lelle@...]$ db2 'select count(*) from price'

1
-----------
11765
:-)

Try:

db2 'select * from proj where deptno <> 'E21''

--
Helmut K. C. Tessarek
DB2 Performance and Development

/*
Thou shalt not follow the NULL pointer for chaos and madness
await thee at its end.
*/

Reply With Quote
  #8  
Old   
danfan46
 
Posts: n/a

Default Re: CLP giving weird error code for simple SQL - 05-21-2010 , 12:45 AM



Lennart Jonsson wrote:
Quote:
On 2010-05-21 02:07, Helmut Tessarek wrote:
You have to use double quotes in a UNIX shell as well.

My first reaction as well, but it actually worked with quotes:

[lelle@...]$ db2 'select count(*) from price'

The difference between single and double qoutes is that
within double quotes the shell with perform shell variable subsitution,
between single qoutes not.

echo "$HOSTNAME" ==> myhost
echo '$HOSTNAME' ==> $HOSTNAME


Quote:
1
-----------
11765

1 record(s) selected.


On 20.05.10 14:17 , Morch wrote:
[...]
Stupid Windoze.


Agreed ;-)


/Lennart

Reply With Quote
  #9  
Old   
Serge Rielau
 
Posts: n/a

Default Re: CLP giving weird error code for simple SQL - 05-21-2010 , 01:56 AM



Try db2 "SELECT * FROM "myTable""
;-)


--
Serge Rielau
SQL Architect DB2 for LUW
IBM Toronto Lab

Reply With Quote
  #10  
Old   
Helmut Tessarek
 
Posts: n/a

Default Re: CLP giving weird error code for simple SQL - 05-21-2010 , 02:24 AM



Good point.

[db2inst1@tessus2 ~]$ db2 "select * from "myTable""
SQL0204N "DB2INST1.MYTABLE" is an undefined name. SQLSTATE=42704
[db2inst1@tessus2 ~]$ db2 "select * from \"myTable\""

C1
-----------

0 record(s) selected.

But
db2 'select * from proj where deptno <> \'E21\''
does not work.

That is the reason why I never use single quotes...

On 21.05.10 2:56 , Serge Rielau wrote:
Quote:
Try db2 "SELECT * FROM "myTable""
;-)


--
Helmut K. C. Tessarek
DB2 Performance and Development

/*
Thou shalt not follow the NULL pointer for chaos and madness
await thee at its end.
*/

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.