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.

 
Go Back  dBforums > Database Server Software > DB2 > Connecting to a particular schema using ODBC.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-13-05, 11:25
yadu yadu is offline
Registered User
 
Join Date: Oct 2005
Posts: 16
Connecting to a particular schema using ODBC.

Hi,

Is it possible to configure a DSN Connection to connect to a particular Schema.

DB2 is the database and i want to connect to a particular schema.

TIA
Yadu
Reply With Quote
  #2 (permalink)  
Old 10-13-05, 11:34
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
You don't connect to a schema; you connect to a database.

Please explain in detail what are you trying to achieve.
Reply With Quote
  #3 (permalink)  
Old 10-13-05, 12:09
yadu yadu is offline
Registered User
 
Join Date: Oct 2005
Posts: 16
I've a database called as "SAMPLE" which is in Schema "Test".

I've created a DSN for this database using a login "db2admin".

Whenever I try to connect to this database, the schema is defaulted is "db2admin". To overcome this, the schema name has to be mentioned in the code which is accessing the database.

To avoid this hardcoding of schema name in the code, I'm looking for something like a parameter in DSN where in i can mention a default schema name.

I've tried using the CLISCHEMA option but it does not work.

Both the client and the database reside on windows env.

Yadu
Reply With Quote
  #4 (permalink)  
Old 10-13-05, 12:17
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Quote:
Originally Posted by yadu
To overcome this, the schema name has to be mentioned in the code which is accessing the database.
It is a good development practice to specify schema names in your SQL.

If you insist on doing wrong things you can either issue SET CURRENT SCHEMA statement or specify "CurrentSchema=whatever" in db2cli.ini
Reply With Quote
  #5 (permalink)  
Old 10-14-05, 05:24
yadu yadu is offline
Registered User
 
Join Date: Oct 2005
Posts: 16
Question

I added the schema name in db2cli.ini file.

The results were a bit odd.

Though I did not get any errors, the resulting query did not return any of the data from the table.

Can you tell me what could be the reason for this?

PS: The table is having valid data which satisfies the query condition.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On