473,412 Members | 4,519 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

INHERIT SPECIAL REGISTERS

Friends:

I have a stored procedure declared as:

CREATE PROCEDURE X.Y
LANGUAGE SQL
DYNAMIC RESULT SETS 1
READS SQL DATA
SPECIFIC Y
INHERIT SPECIAL REGISTERS
CALLED ON NULL INPUT
BEGIN
....

Let's say all this SP does is "select * from table X" and return the
result set, and that X exists in schemas S1 and S2. Further, X is empty
in schema S1 but populated in S2. Lastly, when I created the SP, my
current schema was set to S1.

If I execute SET SCHEMA S2 and call the procedure, I get no rows, even
though X is populated there *and* I have "INHERIT SPECIAL REGISTERS"
declared (which, anyway, I thought was the default). The only way my SP
will read X in S2 is if I drop it, SET SCHEMA S2, and recreate the SP.
I of course have to SET SCHEMA to some value where the table referenced
in the SP actually exists, otherwise I get an object not found error.

I thought INHERIT SPECIAL REGISTERS was the answer to the "SP exists
here, but the objects it works with are over here" question, but it
doesn't seem to be working as I understand it to be documented. I'd
imagine the requirement to have a centralized SP that can run against
objects in multiple schemas is fairly common, so what am I doing wrong?

BTW, when I select QUALIFIER and SPEC_REG FROM SYSCAT.ROUTINES, I see
the schema I was set to before I issued the create (as expected), and
'I', respectively. SOURCESCHEMA is NULL.

Env: DB2 LUW 8.3, AIX 5.x

Thanks,

--Jeff

Jul 28 '06 #1
3 4146
jefftyzzer wrote:
Friends:

I have a stored procedure declared as:

CREATE PROCEDURE X.Y
LANGUAGE SQL
DYNAMIC RESULT SETS 1
READS SQL DATA
SPECIFIC Y
INHERIT SPECIAL REGISTERS
CALLED ON NULL INPUT
BEGIN
...

Let's say all this SP does is "select * from table X" and return the
result set, and that X exists in schemas S1 and S2. Further, X is empty
in schema S1 but populated in S2. Lastly, when I created the SP, my
current schema was set to S1.

If I execute SET SCHEMA S2 and call the procedure, I get no rows, even
though X is populated there *and* I have "INHERIT SPECIAL REGISTERS"
declared (which, anyway, I thought was the default). The only way my SP
will read X in S2 is if I drop it, SET SCHEMA S2, and recreate the SP.
I of course have to SET SCHEMA to some value where the table referenced
in the SP actually exists, otherwise I get an object not found error.

I thought INHERIT SPECIAL REGISTERS was the answer to the "SP exists
here, but the objects it works with are over here" question, but it
doesn't seem to be working as I understand it to be documented. I'd
imagine the requirement to have a centralized SP that can run against
objects in multiple schemas is fairly common, so what am I doing wrong?

BTW, when I select QUALIFIER and SPEC_REG FROM SYSCAT.ROUTINES, I see
the schema I was set to before I issued the create (as expected), and
'I', respectively. SOURCESCHEMA is NULL.

Env: DB2 LUW 8.3, AIX 5.x
In general special registers apply to dynamic SQL only.
So if you want the schema of a query to be influenced by the outside
world then you need to use PREPARE and a dynamic cursor.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/
Jul 28 '06 #2
Thanks, Serge. An experiment and a more careful reading of the CURRENT
SCHEMA entry in V1 of the SQL Reference confirms your reply:

"The CURRENT SCHEMA ...special register specifies a...value that
identifies the schema name used to qualify database object
references...in dynamically prepared SQL statements.... The QUALIFIER
bind option controls the schema name used to qualify database object
references...for static SQL statements."

Looks like I'll be rewriting some FOR loops and EXECUTing IMMEDIATE a
DELETE and INSERT.

Regards,

--Jeff

Serge Rielau wrote:
jefftyzzer wrote:
Friends:

I have a stored procedure declared as:

CREATE PROCEDURE X.Y
LANGUAGE SQL
DYNAMIC RESULT SETS 1
READS SQL DATA
SPECIFIC Y
INHERIT SPECIAL REGISTERS
CALLED ON NULL INPUT
BEGIN
...

Let's say all this SP does is "select * from table X" and return the
result set, and that X exists in schemas S1 and S2. Further, X is empty
in schema S1 but populated in S2. Lastly, when I created the SP, my
current schema was set to S1.

If I execute SET SCHEMA S2 and call the procedure, I get no rows, even
though X is populated there *and* I have "INHERIT SPECIAL REGISTERS"
declared (which, anyway, I thought was the default). The only way my SP
will read X in S2 is if I drop it, SET SCHEMA S2, and recreate the SP.
I of course have to SET SCHEMA to some value where the table referenced
in the SP actually exists, otherwise I get an object not found error.

I thought INHERIT SPECIAL REGISTERS was the answer to the "SP exists
here, but the objects it works with are over here" question, but it
doesn't seem to be working as I understand it to be documented. I'd
imagine the requirement to have a centralized SP that can run against
objects in multiple schemas is fairly common, so what am I doing wrong?

BTW, when I select QUALIFIER and SPEC_REG FROM SYSCAT.ROUTINES, I see
the schema I was set to before I issued the create (as expected), and
'I', respectively. SOURCESCHEMA is NULL.

Env: DB2 LUW 8.3, AIX 5.x
In general special registers apply to dynamic SQL only.
So if you want the schema of a query to be influenced by the outside
world then you need to use PREPARE and a dynamic cursor.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/
Jul 28 '06 #3
jefftyzzer wrote:
Thanks, Serge. An experiment and a more careful reading of the CURRENT
SCHEMA entry in V1 of the SQL Reference confirms your reply:

"The CURRENT SCHEMA ...special register specifies a...value that
identifies the schema name used to qualify database object
references...in dynamically prepared SQL statements.... The QUALIFIER
bind option controls the schema name used to qualify database object
references...for static SQL statements."

Looks like I'll be rewriting some FOR loops and EXECUTing IMMEDIATE a
DELETE and INSERT.
Keep in mind that by default dynamic SQL executes under "invoker's
rights". You can modify that by setting the respective bind options via
the SET_ROUTINE_OPTS() procedure.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/
Jul 28 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

44
by: Frank Rizzo | last post by:
Any ideas?
1
by: Spurry Moses | last post by:
Hi, I'm converting a project from C++Builder to C# and I just need to copy my class design across. It's looking good so far. To stick with the design I want to inherit from a ComboBox control...
3
by: Ruby Deepdelver | last post by:
Hello, I'm having trouble in find certain information, i've search over the web and through the documentation but i haven't had lucky. I need to know if there is some limit in the amount of...
2
by: svendtofte | last post by:
Hello, I've used wsdl.exe, to generate stub code for a WS at work. an example of the stub code is: ========================== /// <remarks/> public abstract class NavigatePublicationTarget :...
2
by: neat2006 | last post by:
This is somewhat of a strange issue. Allow me to detail it as much as I can. We use the Blackboard Transaction System (BTS) for all students dinning services. The "ENVISION" server is Running...
0
by: neat2006 | last post by:
This is somewhat of a strange issue. Allow me to detail it as much as I can. We use the Blackboard Transaction System (BTS) for all students dinning services. The "ENVISION" server is Running...
0
by: neat2006 | last post by:
This is somewhat of a strange issue. Allow me to detail it as much as I can. We use the Blackboard Transaction System (BTS) for all students dinning services. The "ENVISION" server is Running...
7
by: MisterPete | last post by:
How can I inherit from file but stil create an instance that writes to stdout? ----------- I'm writing a file-like object that has verbosity options (among some other things). I know I could just...
1
by: swami | last post by:
In Db2 How to view the values of special registers like CURRENT SCHEMA CURRENT PATH , etc ?
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.