Running DB2 Express-C 9.7.2 and DB2 LUW Enterprise 9.7
I am trying to create and use a user defined function that mirrors one in the database that I am porting from.
Quote:
|
CREATE FUNCTION A_FUNCTION ...;
|
The function is created within the currently active schema (CURRENT_SCHEMA - a synonmym of CURRENT SQLID).
Whereas the function search path CURRENT {FUNCTION} PATH doesn't contain the current schema but contains the current user.
returns
Quote:
|
"SYSIBM","SYSFUN","SYSPROC","SYSIBMADM","DB2AD MIN"
|
where DB2ADMIN is the value of the special register [I]USER{/I].
This seems counterintuitive to me; Functions and procedures are created in schemas and the search path to find them contains the logged on user rather than the current schema.
If I create the FUNCTION under the userid we are going to be running as...
Quote:
|
CREATE FUNCTION A_USER.A_FUNCTION ...;
|
This creates a schema of A_USER and puts A_FUNCTION in there.
But if I issue
Quote:
|
SET SESSION AUTHORIZATION 'A_USER'
|
This correctly updates the [I]USER{/I] special register but the
CURRENT_PATH special register still refers to the original user DB2ADMIN.
Again this seems like a bug in that the CURRENT_PATH special register is not updated when USER special register changes.
I could create the function in DB2ADMIN but I don't want to be logged on as that all of the time so DB2ADMIN wouldn't be in the path when logged on as someone else.
I can update the currrent path special register using...
Quote:
|
SET PATH = CURRENT_PATH, "MY_SCHEMA";
|
But this is only for the current transaction and I'd rather not have to change hundreds of SQL scripts to add a SET PATH or qualify the function calls.
How do I get the correct schema added to the PATH?
Thanks,
Mark.