473,386 Members | 1,726 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.

procedures and table scope... PLS-00201

I'm having trouble writing a simple procedure.

I'm trying to simply select against a table in a different schema.

I first wrote a simple procedure that selected against a table in my
schema, which worked.

CREATE OR REPLACE PROCEDURE test
IS
CURSOR cur_test
IS
select *
from tablename;
BEGIN
FOR itemrec IN cur_test
LOOP
DBMS_OUTPUT.PUT_LINE('record!');

END LOOP;
END test;

A simple change to this is to change my select line to:

select *
from otherTablespace.tablename;

This gives me an error saying "otherTablespace.tablename must be
declared."

My first thought was to create a public synonym, so I did.

CREATE PUBLIC SYNONYM mySyn FOR otherTablespace.tablename

I also change my select line to read:

select *
from mySyn

PLS-00201: identifier mySyn' must be declared.

What am I missing? Why can't I "see" the other schemas table in a
procedure even when explicitly referenced using the
tablespace.tablename?

I am able to access the table through SQLPlus...?

Thanks.

_Am
Jul 19 '05 #1
4 27927
VC
Hello Andrew,

A privilege ('select/update/delete') has to be granted directly to the
procedure executor, not via a role.

sqlplus can read the table because the access is granted via a role.

Rgds.

"Andrew Metcalfe" <ch*********@hotmail.com> wrote in message
news:a2*************************@posting.google.co m...
I'm having trouble writing a simple procedure.

I'm trying to simply select against a table in a different schema.

I first wrote a simple procedure that selected against a table in my
schema, which worked.

CREATE OR REPLACE PROCEDURE test
IS
CURSOR cur_test
IS
select *
from tablename;
BEGIN
FOR itemrec IN cur_test
LOOP
DBMS_OUTPUT.PUT_LINE('record!');

END LOOP;
END test;

A simple change to this is to change my select line to:

select *
from otherTablespace.tablename;

This gives me an error saying "otherTablespace.tablename must be
declared."

My first thought was to create a public synonym, so I did.

CREATE PUBLIC SYNONYM mySyn FOR otherTablespace.tablename

I also change my select line to read:

select *
from mySyn

PLS-00201: identifier mySyn' must be declared.

What am I missing? Why can't I "see" the other schemas table in a
procedure even when explicitly referenced using the
tablespace.tablename?

I am able to access the table through SQLPlus...?

Thanks.

_Am

Jul 19 '05 #2
When are you refering a table in Stored procedure from other schema
you need to grant the select on that table directly without involving
any role.

Faheem

"
VC" <bo*******@hotmail.com> wrote in message news:<m8oCb.375468$ao4.1254277@attbi_s51>...
Hello Andrew,

A privilege ('select/update/delete') has to be granted directly to the
procedure executor, not via a role.

sqlplus can read the table because the access is granted via a role.

Rgds.

"Andrew Metcalfe" <ch*********@hotmail.com> wrote in message
news:a2*************************@posting.google.co m...
I'm having trouble writing a simple procedure.

I'm trying to simply select against a table in a different schema.

I first wrote a simple procedure that selected against a table in my
schema, which worked.

CREATE OR REPLACE PROCEDURE test
IS
CURSOR cur_test
IS
select *
from tablename;
BEGIN
FOR itemrec IN cur_test
LOOP
DBMS_OUTPUT.PUT_LINE('record!');

END LOOP;
END test;

A simple change to this is to change my select line to:

select *
from otherTablespace.tablename;

This gives me an error saying "otherTablespace.tablename must be
declared."

My first thought was to create a public synonym, so I did.

CREATE PUBLIC SYNONYM mySyn FOR otherTablespace.tablename

I also change my select line to read:

select *
from mySyn

PLS-00201: identifier mySyn' must be declared.

What am I missing? Why can't I "see" the other schemas table in a
procedure even when explicitly referenced using the
tablespace.tablename?

I am able to access the table through SQLPlus...?

Thanks.

_Am

Jul 19 '05 #3
Thanks, Rgds and Faheem you both hit the nail straight on.

_Am

fa*******@yahoo.com (FaheemRao) wrote in message news:<43*************************@posting.google.c om>...
When are you refering a table in Stored procedure from other schema
you need to grant the select on that table directly without involving
any role.

Faheem

Jul 19 '05 #4
Thanks, Rgds and Faheem you both hit the nail straight on.

_Am

fa*******@yahoo.com (FaheemRao) wrote in message news:<43*************************@posting.google.c om>...
When are you refering a table in Stored procedure from other schema
you need to grant the select on that table directly without involving
any role.

Faheem

Jul 19 '05 #5

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

Similar topics

17
by: serge | last post by:
How can i delete all user stored procedures and all table triggers very fast in a single database? Thank you
7
by: pkruti | last post by:
Below is a stored procedure i am working with and i am trying to drop the yesno_holding table if it exists but how do i add it back? Meaning i want it to drop if it exists but i want to add it back...
7
by: BlueDragon | last post by:
The place where I work is moving to MS SQL Server from Lotus Notes. I have done a lot of coding in Lotus Notes, and have, I suppose, intermediate skills in basic SQL -- queries, insert, updates,...
5
by: Neil Zanella | last post by:
Hello, I am curious as to why the designers of C did not include support for Pascal-like nested procedures. I guess that it's because nested procedures in C would not buy you much other than...
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
4
by: dhruv19280 | last post by:
Can someone confirm that DB2 UDB v8.1.2 does NOT support internal procedures as supported by Oracle? For example, this would work in Oracle, but not in DB2. Am I correct? CREATE OR REPLACE...
1
by: Jon Haakon Ariansen | last post by:
Hi all, I don't know where to publish this question but hope this newsgroup is okey. I'm working in Visual Studio 2005 and are now creating a dataset file where I will do all the transactions...
1
by: jobs | last post by:
I have a growning list of stored procedures that accept a single string as a parameter. The list and parameters are maintained in a table with two columns. Some of the Stored procedures take...
3
by: Otto Carl Marte | last post by:
Hi, As I understand it, Declared Global Temporary Tables (DGTTs) have a scope that is session/connection based. Using the same connection, I have discovered that if I declare a DGTT in one...
3
by: codefragment | last post by:
Hi I have a chunky bit of sql that I will want to call from a number of places. It will return a few thousand rows. Whats the best way of structuring this? 1) I initially thought of using...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
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...

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.