| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |

03-13-09, 10:23
|
|
Registered User
|
|
Join Date: Mar 2009
Posts: 21
|
|
|
Error when counting the records for table name starting with '/'
|
|
Hi All,
I am using the following sql to count the records from a table that is starting with '/'. the error is as follows.
I am using DB2 v9.1.5
OS - AIX 5.3
db2 "select count(*) from SAPDB1./BIC/AZAR_D0500"
SQL0104N An unexpected token "count(*) from SAPDB1." was found following
"select ". Expected tokens may include: "<term>". SQLSTATE=42601
Please help.
Thanks
Raja
|
|

03-13-09, 10:42
|
|
:-)
|
|
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
|
|
Try putting the table name in double quotes. Obviously, you will have to escape them because they will be withing another quoted string.
|
|

03-13-09, 10:51
|
|
Registered User
|
|
Join Date: Mar 2009
Posts: 21
|
|
|
|
Hi Nick, Thanks for ur reply.. I am trying like this but still it is giving error.. correct me in the syntax if it is wrong.
db2 select count(*) from "/BIC/AZAR_D0500"
ksh: 0403-057 Syntax error: `(' is not expected.
|
|

03-13-09, 12:58
|
|
:-)
|
|
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
|
|
You have to quote the entire statement AND the table name.
|
|

03-13-09, 12:59
|
|
Registered User
|
|
Join Date: Sep 2003
Posts: 237
|
|
Try db2 "select count(*) from '/BIC/AZAR_D0500' "
__________________
mota
|
|

03-13-09, 13:00
|
|
:-)
|
|
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
|
|
Quote:
|
Originally Posted by dbamota
Try db2 "select count(*) from '/BIC/AZAR_D0500' "
|
Not gonna work. Must be double quotes, like I said.
|
|

03-13-09, 14:18
|
|
Registered User
|
|
Join Date: Mar 2009
Posts: 21
|
|
db2db1> db2 "select count(*) from SAPDB1."/BIC/AZAR_D0500""
SQL0104N An unexpected token "count(*) from SAPDB1." was found following
"select ". Expected tokens may include: "<term>". SQLSTATE=42601
db2db1> db2 "select count(*) from SAPDB1.'/BIC/AZAR_D0500'"
SQL0104N An unexpected token "'/BIC/AZAR_D0500'" was found following "ount(*)
from SAPDB1.". Expected tokens may include: "<identifier>". SQLSTATE=42601
db2db1> db2 "select count(*) from "SAPDB1"."/BIC/AZAR_D0500""
SQL0104N An unexpected token "count(*) from SAPDB1." was found following
"select ". Expected tokens may include: "<term>". SQLSTATE=42601
None of these has worked..
|
|

03-13-09, 14:49
|
|
:-)
|
|
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
|
|
|
|

03-13-09, 15:00
|
|
Registered User
|
|
Join Date: Sep 2003
Posts: 237
|
|
Did you try db2 "select count(*) from 'SAPDB1./BIC/AZAR_D0500'"
You have to put the total table name within single quote
__________________
mota
|
|

03-13-09, 16:54
|
|
Registered User
|
|
Join Date: Mar 2009
Posts: 21
|
|
yes but did not work..i tried with single quote as well double quote...
|
|

03-13-09, 19:11
|
|
Registered User
|
|
Join Date: Jan 2009
Posts: 8
|
|
please try it with "select count(*) from SAPDB1./BIC/AZAR_D0500".
|
|

03-13-09, 20:10
|
|
Registered User
|
|
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
|
|
Wouldn't the following work?
Code:
db2 'select count(*) from SAPDB1."/BIC/AZAR_D0500" '
Or otherwise try
Code:
db2 'select count(*) from "SAPDB1./BIC/AZAR_D0500" '
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/
|
|

03-14-09, 02:19
|
|
Registered User
|
|
Join Date: May 2007
Location: somewhere in dbforums
Posts: 221
|
|
In OS command prompt you can try
Quote:
|
db2 "select count(*) from SAPDB1.\"/BIC/AZAR_D0500\""
|
note that the ' \' here acts as an escape character to your "
In the db2 command prompt you can try
Quote:
|
select count(*) from SAPDB1."/BIC/AZAR_D0500"
|
both will work
__________________
IBM Certified Database Associate, DB2 9 for LUW
|
|

03-15-09, 15:31
|
|
Registered User
|
|
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
|
|
Quote:
|
Originally Posted by dbamota
Did you try db2 "select count(*) from 'SAPDB1./BIC/AZAR_D0500'"
You have to put the total table name within single quote
|
That will never work because a single quote is a string delimiter while you have to use double-quotes for delimited identifiers. You will have to switch single and double quotes here.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
|
|

03-16-09, 16:04
|
|
Registered User
|
|
Join Date: Sep 2003
Posts: 237
|
|
Created table as follows
db2test2@egudbw:/dbhome/db2test2/bas> cat zz
CREATE TABLE COMMON."/BIC/AZAR_D0500"(
MSG_ID VARCHAR(30),
MESSAGE VARCHAR(255)
) in userspace1;
created a file y
db2test2@egudbw:/dbhome/db2test2/bas> cat y
select count(*) from COMMON."/BIC/AZAR_D0500";
db2test2@egudbw:/dbhome/db2test2/bas> db2 -tvf y
select count(*) from COMMON."/BIC/AZAR_D0500"
1
-----------
0
__________________
mota
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|