473,386 Members | 1,720 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,386 software developers and data experts.

SQL Stored Proc - Security issue

Hi All;
I am having trouble with a very simple SQL stored procedure. I have
written several that are running with no problems. This one is leaving
me scratching my head. I suspect I'm missing something very simple and
appreciate your help. Here goes:
* This SQL runs fine from command line:
select APPLY_QUAL, rtrim(SET_NAME) as SET_NAME
, SOURCE_OWNER, SOURCE_TABLE, TARGET_OWNER
, TARGET_TABLE, TARGET_CONDENSED, TARGET_COMPLETE
from ASN.IBMSNAP_SUBS_MEMBR;
* When put into the body of a CREATE PROCEDURE statement like so:
CREATE PROCEDURE SPPCH.DPROP_SET_ACTIVITY
(
)
DYNAMIC RESULT SETS 1
LANGUAGE SQL
NOT DETERMINISTIC
CALLED ON NULL INPUT
READS SQL DATA
INHERIT SPECIAL REGISTERS
BEGIN
DECLARE SQLCODE INTEGER DEFAULT 0 ;

-- use WITH RETURN TO CLIENT in DECLARE CURSOR to always
-- return a result set to the client application
DECLARE c1 CURSOR WITH RETURN TO CALLER FOR
select APPLY_QUAL, rtrim(SET_NAME) as SET_NAME
, SOURCE_OWNER, SOURCE_TABLE, TARGET_OWNER
, TARGET_TABLE, TARGET_CONDENSED, TARGET_COMPLETE
from ASN.IBMSNAP_SUBS_MEMBR;

-- to return result set, do not CLOSE cursor
OPEN c1;

-- the EXIT handler ensures that we will not reach this point unless
the
-- result set has results, so we can return a success code
END;
* The CREATE PROCEDURE statement fails with:
[DB2/6000] SQL0551N "SPXXX" does not have the privilege to perform
operation "SELECT" on object "ASN.IBMSNAP_SUBS_MEMBR". LINE NUMBER=26.
SQLSTATE=42501
* SPXXX is a member of a group which has select on the specified object
and SPXXX can run the SQL SELECT statement and return results from the
command line.

Any ideas on what I'm missing? I can find no solution in the App Dev
Guide for Server Apps. Thanks in advance.

Pete H

Nov 12 '05 #1
2 2239
peteh wrote:
Hi All;
I am having trouble with a very simple SQL stored procedure. I have
written several that are running with no problems. This one is leaving
me scratching my head. I suspect I'm missing something very simple and
appreciate your help. Here goes:
* This SQL runs fine from command line:
select APPLY_QUAL, rtrim(SET_NAME) as SET_NAME
, SOURCE_OWNER, SOURCE_TABLE, TARGET_OWNER
, TARGET_TABLE, TARGET_CONDENSED, TARGET_COMPLETE
from ASN.IBMSNAP_SUBS_MEMBR;
* When put into the body of a CREATE PROCEDURE statement like so:
CREATE PROCEDURE SPPCH.DPROP_SET_ACTIVITY
(
)
DYNAMIC RESULT SETS 1
LANGUAGE SQL
NOT DETERMINISTIC
CALLED ON NULL INPUT
READS SQL DATA
INHERIT SPECIAL REGISTERS
BEGIN
DECLARE SQLCODE INTEGER DEFAULT 0 ;

-- use WITH RETURN TO CLIENT in DECLARE CURSOR to always
-- return a result set to the client application
DECLARE c1 CURSOR WITH RETURN TO CALLER FOR
select APPLY_QUAL, rtrim(SET_NAME) as SET_NAME
, SOURCE_OWNER, SOURCE_TABLE, TARGET_OWNER
, TARGET_TABLE, TARGET_CONDENSED, TARGET_COMPLETE
from ASN.IBMSNAP_SUBS_MEMBR;

-- to return result set, do not CLOSE cursor
OPEN c1;

-- the EXIT handler ensures that we will not reach this point unless
the
-- result set has results, so we can return a success code
END;
* The CREATE PROCEDURE statement fails with:
[DB2/6000] SQL0551N "SPXXX" does not have the privilege to perform
operation "SELECT" on object "ASN.IBMSNAP_SUBS_MEMBR". LINE NUMBER=26.
SQLSTATE=42501
* SPXXX is a member of a group which has select on the specified object
and SPXXX can run the SQL SELECT statement and return results from the
command line.

Any ideas on what I'm missing? I can find no solution in the App Dev
Guide for Server Apps. Thanks in advance.

Pete H

GROUP privileges are only considered for dynamic SQL.
For static SQL (such as that used in an SQL Procedure) the user must
have explicit privileges.

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #2
As usual - Thanks!

Pete H

Nov 12 '05 #3

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

Similar topics

3
by: bigDWK | last post by:
Hi- I'm having problems with the following stored procedure. Below first I have the stored proc, then I have the asp code that calls it. Randomly it won't insert the order into the database and a...
3
by: Cliff | last post by:
here's my stored procedure: CREATE PROCEDURE proc @id varchar(50),@pswd varchar(20),@no_go int OUTPUT AS SET NOCOUNT ON SELECT user_id FROM profile WHERE user_id=\@id AND pswd=\@pswd IF...
9
by: Wolfgang Kreuzer | last post by:
Try hard to become familiar with T-SQL. Can anybodey tell me the best way to deal with set's provided by a stored procedure. Til yesterday I thougt trapping set in temp table using INSERT EXEC...
2
by: Mike Hutton | last post by:
I have a rather odd problem. I have a SP which uses temp. tables along the way, and then returns a table of results: CREATE PROCEDURE dbo.usp_myproc( @pNameList VARCHAR(6000) ) AS
45
by: John | last post by:
Hi When developing vb.bet winform apps bound to sql server datasource, is it preferable to use SELECTs or stored procedure to read and write data from/to SQL Server? Why? Thanks Regards
28
by: mooreit | last post by:
The purpose for my questions is accessing these technologies from applications. I develop both applications and databases. Working with Microsoft C#.NET and Microsoft SQL Server 2000 Production and...
12
by: Jason Huang | last post by:
Hi, In my C# Windows Form application project, I have done all queries on my codes. Now I wanna try using the Stored Procedure. But I am not clear about why using the stored procedure. Would...
1
by: central_scrutinizer | last post by:
I have an ASP that has been working fine for several months, but it suddenly broke. I wonder if windows update has installed some security patch that is causing it. The problem is that I am...
0
by: ravindrag | last post by:
Hi, I am getting error SQL1131N during sqlj.install_jar(...). There is no useful message in the diag.log (even with diag level 4). I am giving the diag.log entries at the end of this posting...
0
by: mirandacascade | last post by:
Questions toward the bottom of the post. Situation is this: 1) Access 97 2) SQL Server 2000 3) The Access app: a) sets up pass-thru query b) .SQL property of querydef is a string, the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.