Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

sql error:SQL0206N in db2 v9.1

Posted on 2011-03-03
15
Medium Priority
?
1,151 Views
Last Modified: 2012-05-11

Hi

I am getting the below error which selecting a column from the table

$ db2 "select COMPANY_CODE_CURRENCY from COGNOS.DIM_COMPANY_CODE_SPEND"
SQL0206N  "COMPANY_CODE_CURRENCY" is not valid in the context where it is
used.  SQLSTATE=42703


But, the same column is accesable when I select by using a * or count(*)..Its giving result

Please suggets me a solution for this
0
Comment
Question by:jmartin_v
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 5
15 Comments
 
LVL 46

Expert Comment

by:Kent Olsen
ID: 35026817
Hi jmartin,

Have you done a "db2 connect" prior to this call to db2?  You need an active connection to the database.


Kent
0
 

Author Comment

by:jmartin_v
ID: 35026983
yes, db2 is connected and

As I mentioned, I am able to get the result with the select * and select count(*) and also able to query other columns except the above mentioned column "COMPANY_CODE_CURRENCY "
0
 
LVL 46

Expert Comment

by:Kent Olsen
ID: 35027042
Ok.  Try the SQL below:

db2  "select * from sysibm.tables where table_schema = 'COGNOS' and table_name = 'COMPANY_CODE_CURRENCY'"


Kent
0
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 

Author Comment

by:jmartin_v
ID: 35027138
Hi guys,
let me post the issue in details

the table description is : tablename = "DIM_COMPANY_CODE_SPEND"

Column                         Type      Type
name                           schema    name               Length   Scale Nulls
------------------------------ --------- ------------------ -------- ----- ------
COMPANY_CODE_SKEY              SYSIBM    INTEGER                   4     0 No
COMPANY_CODE                   SYSIBM    CHARACTER                10     0 Yes
COMPANY_CODE_CURRENCY          SYSIBM    CHARACTER                 3     0 Yes
COMPANY_CODE_DESCRIPTION       SYSIBM    CHARACTER               100     0 Yes
PARENT_COMPANY_SKEY            SYSIBM    INTEGER                   4     0 No
CREATE_DATE                    SYSIBM    DATE                      4     0 No
CREATED_BY                     SYSIBM    CHARACTER                10     0 Yes
LAST_UPDATE_DATE               SYSIBM    DATE                      4     0 Yes
LAST_UPDATED_BY                SYSIBM    CHARACTER                10     0 Yes


when I query the table "DIM_COMPANY_CODE_SPEND" using the below queries

select * from cognos.DIM_COMPANY_CODE_SPEND or

select count(*) from cognos.DIM_COMPANY_CODE_SPEND or

select COMPANY_CODE, COMPANY_CODE_SKEY from cognos.DIM_COMPANY_CODE_SPEND

I am able to get the result(even with other columns except the COMPANY_CODE_CURRENCY column)

when I query the db using the below query:

$ db2 "select COMPANY_CODE_CURRENCY from COGNOS.DIM_COMPANY_CODE_SPEND"
SQL0206N  "COMPANY_CODE_CURRENCY" is not valid in the context where it is
used.  SQLSTATE=42703

I get the above error...
i tried reorg the table and set integrity with no use...Are there any solution to make this column accesable???


0
 
LVL 37

Expert Comment

by:momi_sabag
ID: 35027199
it's pretty far fetch but try

db2 "select COMPANY_CODE_CURRENCY from cognos.DIM_COMPANY_CODE_SPEND"
0
 

Author Comment

by:jmartin_v
ID: 35027258
I have pasted the output of the query qith you sent me above :

$ db2 "select COMPANY_CODE_CURRENCY from COGNOS.DIM_COMPANY_CODE_SPEND"

SQL0206N  "COMPANY_CODE_CURRENCY" is not valid in the context where it is
used.  SQLSTATE=42703
0
 

Author Comment

by:jmartin_v
ID: 35027302
The issue is with the column  "COMPANY_CODE_CURRENCY" only

db2 "select COMPANY_CODE_CURRENCY from COGNOS.DIM_COMPANY_CODE_SPEND"

only when I query this particular column seperately I get an error:

SQL0206N  "COMPANY_CODE_CURRENCY" is not valid in the context where it is
used.  SQLSTATE=42703

0
 
LVL 46

Expert Comment

by:Kent Olsen
ID: 35027579
Hi Jmartin,

The "description" that you posted above is for a table (view) in the SYSIBM schema.  You're querying the COGNOS schema.


Kent
0
 

Author Comment

by:jmartin_v
ID: 35027858
yes, its the cognos schema..I tried to query using the cognos schema
0
 

Author Comment

by:jmartin_v
ID: 35027960
hi Kdo,

the schema is cognos only,


Table/View                      Schema          Type  Creation time
------------------------------- --------------- ----- --------------------------
DIM_ADDRESSABLE_SPEND           COGNOS          T     2011-02-08-13.29.50.693383
DIM_CATEGORY_LEVEL_SPEND        COGNOS          T     2011-02-08-13.29.51.531685
DIM_CLEARING_DOCUMENT_SPEND     COGNOS          T     2011-02-08-13.29.52.750385
DIM_CLEARING_DOCUMENT_SPEND_EX  COGNOS          T     2011-02-11-06.33.17.404292

the table schema is cognos only

i'm little confused here, Do you mean that the columns should also be under the cognos schema???

0
 

Author Comment

by:jmartin_v
ID: 35027966
DIM_COMPANY_CODE_SPEND          COGNOS          T     2011-02-09-09.11.54.975016
0
 
LVL 46

Expert Comment

by:Kent Olsen
ID: 35028758
Do you have any user level authorities defined that could restrict access to column data?

Can you run the query from the schema owner?  How about from the db2 administrator?


Kent
0
 

Author Comment

by:jmartin_v
ID: 35034824
Hi guys the issue was with the column name, there was a space after the name while created so cud not query it..

thanks for the help
0
 
LVL 46

Accepted Solution

by:
Kent Olsen earned 2000 total points
ID: 35035731
Ahhh...

One of the gotchas of quoting names.....


Glad that you found it,
Kent
0
 

Author Closing Comment

by:jmartin_v
ID: 35035767
i have found the solution for the issue
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
Recursive SQL in UDB/LUW (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question