1

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?

user1340582
  • 19,151
  • 35
  • 115
  • 171
  • 1
    I believe this recent question will help you: http://stackoverflow.com/questions/12617787/calling-a-stored-procedures-within-the-same-schema-from-a-sp/12620254#12620254 – dan1111 Oct 03 '12 at 12:17

1 Answers1

1

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