user1340582
user1340582

Reputation: 19699

IBM DB2 9.7, how to explicitly define current schema in SQL

I would like to force the current schema to be the same as current user. It seems to be possible to set current schema in DB2 9.7 with statement: SET SCHEMA '...'

If schema is to be set same as user, is it then: SET SCHEMA USER?

How do I then refer to that schema when e.g. calling a stored procedure?

Upvotes: 1

Views: 4071

Answers (1)

user755404
user755404

Reputation:

You can set the schema...

        .-CURRENT-.          .-=-.
>>-SET--+---------+--SCHEMA--+---+--+-schema-name-----+--------><
                                    +-USER------------+
                                    +-SESSION_USER----+
                                    +-SYSTEM_USER-----+
                                    +-CURRENT_USER----+
                                    +-host-variable---+
                                    '-string-constant-'

http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/admin/r0001016.htm

But for SP you have to use SET PATH...

          .-CURRENT-.          .-=-.
>>-SET--+-+---------+--PATH-+--+---+---------------------------->
        '-CURRENT_PATH------'

   .-,------------------------.
   V                          |
>----+-schema-name----------+-+--------------------------------><
     +-SYSTEM PATH----------+
     +-USER-----------------+
     +-+-CURRENT PATH-+-----+
     | '-CURRENT_PATH-'     |
     +-CURRENT PACKAGE PATH-+
     +-host-variable--------+
     '-string-constant------'

http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/admin/r0001014.htm

Upvotes: 1

Related Questions