Re: Stored procedure selecting from another scheme



On 29 Sep 2005 07:30:40 -0700, "reverland" <reverland@xxxxxxxxx>
wrote:

>When I try to run this stored procedure I get this error
>
>PLS-00201: identifier schema2.table3 must be declared
>
>
>I have looked everywhere and can't find the answer to this. I come from
>a T/SQL background so I am at a loss as to why this doesn't work.
>
>CREATE OR REPLACE procedure schema1.select_ssstudent
>IS
>begin
> select a.*,
> b.*,
> c.sitename
> from schema1.table1 a,
> schema1.table2 b,
> schema2.table3 c
> where a.permnum=b.permnum
> and substr(c.siteid,2,3) = trim(a.schoolnum)
> order by a.schoolnum, UPPER(a.lastname), UPPER(a.firstname);
>end;


I'm not sure why you didn't find this, because this is a a FAQ, as has
been answered at least a 1000 times by me alone.
The answer is : roles are ignored in stored procedures, and you have
privilege through a role. You need either
a) to grant access to the schema1 user directly
b) add authid current_user after the procedure name (assuming you use
8i or higher, you don't mention the version)

To avoid your next question:
in Oracle stored procedures don't return a cursor. You need to look up
how to return a REF CURSOR from a stored procedure.

You are well advised you REALLY should UNLEARN anything you learned
about T/SQL (and sqlserver), and start learning PL/SQL.
Your code betrays you assume Oracle is sqlserver sold by a different
vendor, and PL/SQL is another T/SQL implementation.
You are wrong on both counts.
You definitely need to read at least the first 3 chapters of Oracle
Expert One on One by Thomas Kyte, and the Oracle Concepts Manual.
Otherwise you are going to create unscalable applications.

--
Sybrand Bakker, Senior Oracle DBA
.



Relevant Pages

  • Re: Error in calling stored procedure via DB link
    ... "Paul Clement" wrote: ... Below is an Oracle KB article that documents the issue. ... Calling Stored Procedure over Dblink Using Oracle OleDb Provider Fails ... > symptom: Using command type adCmdStoredProc ...
    (microsoft.public.vb.database.ado)
  • Re: Performance problems with StoredProcedure in Web application
    ... you could probably just ignore my comments about stored procedure performance as compared to textual queries because they ... As for your question about how to avoid using a cursor (as I suggested was possible in Oracle) read the following paragraph for more ... The .NET Framework Data Provider for Oracle does not support batched SQL statements. ... CURSOR output parameters to fill a DataSet, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Passing Back Table Information from Oracle .NET Stored Procedures
    ... stored procedure, not in the typical PL/SQL sense. ... I don't care if it's MS SQL in-line code or Oracle in-line code, MS SQL Server, Oracle Proc, or this so called .NET Stored Procedure using a Select statement, they are all returning a RESULT SET whether it be one row or multiple rows. ... I used SqlContext above because I don't want to bother registering at the Oracle site to download their Oracle Database Extensions for .NET in order to get at the presumably extant OracleContext class. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: EXEC syntax for SP which returns row set
    ... >>> Oracle experts, none of whom seem to know. ... >> SQL> create or replace package returncur is ... > I don't know why you are supplying the above example. ... to illustrate HOW you'd call a stored procedure and return ...
    (comp.databases.oracle.server)
  • Re: inserting XML Document into Oracle database using a stored procedure
    ... What i am trying to do is i want to insert a xml file into the Oracle database using a stored procedure which takes a XmlType type parameter. ...
    (perl.dbi.users)