For example, if we have created a series of tables belonging to the
ASSETMAN schema, can we somehow advise the database server that when
user JOHN connects to this database his default schema is ASSETMAN?
Or do we have to issue a SET SCHEMA command explicitly (presumably at
the beginning of the connection)?
On a related note, in terms of DB2 is it common practice to use a
"default" schema and not explicitly qualify the individual SQL
queries, or is better practice to explicitly qualify every table
reference with the schema name?
I looked for a while and found no way to do this.
> For example, if we have created a series of tables belonging to the
> ASSETMAN schema, can we somehow advise the database server that when
> user JOHN connects to this database his default schema is ASSETMAN?
Luckily, we are using only Java here. So what I did was create a Java
DB2 database connection class that wraps the JDBC connection. I decided
that my default schema should be the same as the database name. Under
the covers, the Java DB2 connection class, after it connects, issues a
"SET SCHEMA <DB>". Works like a charm, and most of the programmers
neither know nor care what schema they are in.
Incidentally, this class also provides connection pooling, and thru a
bit
of NIS black magic, allows for anonymous connections (why hard code your
login and passwd?)
> Or do we have to issue a SET SCHEMA command explicitly (presumably at
> the beginning of the connection)?
> On a related note, in terms of DB2 is it common practice to use a
> "default" schema and not explicitly qualify the individual SQL
> queries, or is better practice to explicitly qualify every table
> reference with the schema name?
Some databasey people here swear that its better to be specific and
explicitly use the schema name. I think its too much typing tho...
Cheers
Allen
Using no schema is better because it makes the code more 'dynamic'.
PM
you may look into db2cli.ini or driver parameters/attributes (connection
url), connection attribute, ...
it depends
PM
We are using SQLAPI under C++. We have the choice of accessing DB2
through either an ODBC DSN or via the native library. So far we're
just using ODBC wrapped by SQLAPI.
> you may look into db2cli.ini or driver parameters/attributes (connection
> url), connection attribute, ...
I'll check that out.
Thanks
Kevin.
For ODBC everything is dynamic - there is no hidden communication - and this
case is no exception. You need to issue the SET command from your program,
and you have to code it yourself.
"Kevin Frey" <kevin_...@hotmail.com> wrote in message
news:e5d907ad.03032...@posting.google.com...
What about ...
CURRENTSCHEMA
Specify the schema used in a SET CURRENT SCHEMA statement upon a successful
connection.
CURRENTSQLID
Specify the ID used in a SET CURRENT SQLID statement sent to the DBMS upon a
successful connection.
This option is only relevant when connecting to those DB2 DBMSs where SET
CURRENT SQLID is supported (such as DB2 for OS/390 and z/OS).
... used in cli/odbc datasources setup in the Config. Assistant?
Aren't they used by odbc?
PM