Why does my function not return anything when I create as a schema object

I have user ABC who owns several tables some of which have foreign key constraints.
I have user XYZ that has been granted access to all tables owned by user ABC.
When I create a function as user XYZ using following I get no return when I issue:
select XYZ.ztm_tables_depended_on('ABC', 'A_TABLE_OWNED_BY_ABC') from dual :
Please see after function definition.
CREATE OR REPLACE FUNCTION ZTM_TABLES_DEPENDED_ON(p_Owner VARCHAR2, p_Table_Name VARCHAR2) RETURN VARCHAR2 IS
  CURSOR C1 IS
  SELECT OWNER, CONSTRAINT_NAME, R_OWNER, R_CONSTRAINT_NAME
  FROM   ALL_CONSTRAINTS
  WHERE  OWNER           = p_Owner
  AND    TABLE_NAME      = p_Table_Name
  AND    CONSTRAINT_TYPE = 'R'
  ORDER  BY OWNER, CONSTRAINT_NAME, R_OWNER, R_CONSTRAINT_NAME;
  v_Referenced_Owner       VARCHAR2(31);
  v_Ret_Val                VARCHAR2(4000);
  FUNCTION CONSTRAINT_TABLE_NAME(p_Owner VARCHAR2, p_Constraint_Name VARCHAR2) RETURN VARCHAR2 IS
    CURSOR C1 IS
    SELECT TABLE_NAME
    FROM   ALL_CONSTRAINTS
    WHERE  OWNER           = p_Owner
    AND    CONSTRAINT_NAME = p_Constraint_Name;
    v_Ret_Val ALL_CONSTRAINTS.TABLE_NAME%TYPE;
  BEGIN
    OPEN  C1;
    FETCH C1 INTO v_Ret_Val;
    CLOSE C1;
    RETURN v_Ret_Val;
  END;
BEGIN
  FOR R IN C1 LOOP
    IF (R.OWNER <> R.R_OWNER) THEN v_Referenced_Owner := R.R_OWNER || '.';
    ELSE                           v_Referenced_Owner := NULL;
    END IF;
    v_Ret_Val := v_Ret_Val || ', ' || v_Referenced_Owner || CONSTRAINT_TABLE_NAME (R.R_OWNER, R.R_CONSTRAINT_NAME);
  END LOOP;
  RETURN LTRIM(v_Ret_Val, ', ');
END;
But, if I embed the function within an anonymous block as follows, I get results:
DECLARE
  CURSOR C1 IS
  select owner, table_name
  FROM   all_tables where owner = 'ABC';
  FUNCTION ZTM_TABLES_DEPENDED_ON(p_Owner VARCHAR2, p_Table_Name VARCHAR2) RETURN VARCHAR2 IS
    CURSOR C1 IS
    SELECT OWNER, CONSTRAINT_NAME, R_OWNER, R_CONSTRAINT_NAME
    FROM   ALL_CONSTRAINTS
    WHERE  OWNER           = p_Owner
    AND    TABLE_NAME      = p_Table_Name
    AND    CONSTRAINT_TYPE = 'R'
    ORDER  BY OWNER, CONSTRAINT_NAME, R_OWNER, R_CONSTRAINT_NAME;
    v_Referenced_Owner       VARCHAR2(31);
    v_Ret_Val                VARCHAR2(4000);
    FUNCTION CONSTRAINT_TABLE_NAME(p_Owner VARCHAR2, p_Constraint_Name VARCHAR2) RETURN VARCHAR2 IS
      CURSOR C1 IS
      SELECT TABLE_NAME
      FROM   ALL_CONSTRAINTS
      WHERE  OWNER           = p_Owner
      AND    CONSTRAINT_NAME = p_Constraint_Name;
      v_Ret_Val ALL_CONSTRAINTS.TABLE_NAME%TYPE;
    BEGIN
      OPEN  C1;
      FETCH C1 INTO v_Ret_Val;
      CLOSE C1;
      RETURN v_Ret_Val;
    END;
  BEGIN
    FOR R IN C1 LOOP
      IF (R.OWNER <> R.R_OWNER) THEN v_Referenced_Owner := R.R_OWNER || '.';
      ELSE                           v_Referenced_Owner := NULL;
      END IF;
      v_Ret_Val := v_Ret_Val || ', ' || v_Referenced_Owner || CONSTRAINT_TABLE_NAME (R.R_OWNER, R.R_CONSTRAINT_NAME);
    END LOOP;
    RETURN LTRIM(v_Ret_Val, ', ');
  END;
BEGIN
  FOR R IN C1 LOOP
    DBMS_OUTPUT.PUT_LINE(ztm_tables_depended_on(R.Owner, R.Table_Name));
  END LOOP;
END;
Any ideas what is happening here?

Any ideas what is happening here?
Justin explained the probable reason.
See the 'How Roles Work in PL/SQL Blocks' section of the database security doc for the details
http://docs.oracle.com/cd/E25054_01/network.1111/e16543/authorization.htm#i1007304
How Roles Work in PL/SQL Blocks
The use of roles in a PL/SQL block depends on whether it is an anonymous block or a named block (stored procedure, function, or trigger), and whether it executes with definer's rights or invoker's rights.
Roles Used in Named Blocks with Definer's Rights
All roles are disabled in any named PL/SQL block (stored procedure, function, or trigger) that executes with definer's rights. Roles are not used for privilege checking and you cannot set roles within a definer's rights procedure.
The SESSION_ROLES view shows all roles that are currently enabled. If a named PL/SQL block that executes with definer's rights queries SESSION_ROLES, then the query does not return any rows.
Roles Used in Named Blocks with Invoker's Rights and Anonymous PL/SQL Blocks
Named PL/SQL blocks that execute with invoker's rights and anonymous PL/SQL blocks are executed based on privileges granted through enabled roles. Current roles are used for privilege checking within an invoker's rights PL/SQL block. You can use dynamic SQL to set a role in the session.
See that line starting with 'All roles are disables in any named PL/SQL block'?

Similar Messages

  • Why does the page not move smothe when i scroll?

    Why does the page not move smothe when i scroll?
    Sometimes it even move slower then i Scroll?
    I use a Mac and i have tried to reinstall the program.

    Start Firefox in [[Safe Mode]] to check if one of the add-ons is causing the problem (switch to the DEFAULT theme: Tools > Add-ons > Appearance/Themes).
    * Don't make any changes on the Safe mode start window.
    In Firefox 4 [http://kb.mozillazine.org/Safe_mode Safe mode] disables extensions and disables hardware acceleration.
    * Tools > Options > Advanced > General > Browsing: "Use hardware acceleration when available"
    See:
    * [[Troubleshooting extensions and themes]]

  • Why does my printer not warn me when my ink is low?

    Why  does my printer not warn  me when my ink is low?
    Before when I used HP control Center it warned me my ink was getting low. Since I instaled HP Conected I no longer get that message."My printer is a HP Deskjet 3050A J611series" 

    are you used original ink from hp ? 

  • Why exchange rate is not displayed correctly when I create the PO in SRM?

    Hi Gurus,
    Yesterday I insert a new row at OB08 tx. at backend system (R/3) for exchange rate of May 17,2010, the value was 10.00. Then I run the BBP_GET_EXRATE program to replicate the info to SRM.
    But when I created a purchase order (PO) the value was 12.24 for exchange rate (this value 12.24 is the value for the previous day May 16, 2010).
    Today morning (May 18, 2010), I inserted another row at R/3 and replicated to SRM, the new value for May 18 was 11. I create another PO and the value was 10 for exchange rate (the value for yesterday).
    But when the PO is transmitted to R/3, the exchange rate is the correct.
    My question is: Why exchange rate is not displayed correctly when I create the PO in SRM? Exists an aspect of memory in SRM that it has to be refreshed? Why SRM is getting the exchange rate for yesterday? Is an issue for time zone?

    Hi Muthu,
    I'm in Extended classic.
    I already discovered what is happening. At the time of being creating the purchase order (PO), it takes the exchange rate of the delivery date of the shopping cart (SC). But when the order is authorized and tries to transmit it to R/3, it takes the exchange rate of the date of creation of the PO.
    Two checks of budget exist:
    1.- When creating PO (exchange rate date of delivery date of the SC's item)
    2.- When authorized and tries to transmit it to R/3 (exchange rate date of creation date of the PO)
    If exchange rate of delivery date of the SC is lower than exchange rate date of creation of the PO, there are cases in which it is marking budget error.
    Now my question is: It is a standard behavior? (to take different exchange rate)

  • Why does my iMac not shut down when I try to shut it down?

    Wh does my iMac not shut down, or restart when I try to do either.  It just sits there with the little loading circle continuously moving.  The only way I can shut it down is if I hold down the power button to shut it down.  Can anyone tell me why this is?
    Thanks!

    Open your Activity Monitor and check to see what is running?
    If there is some important Process running, then it is better to wait until it has finished instead of cutting the power and corrupting who knows what?
    If there is nothing important running, then follow the instructions in the link below for resetting the SMC.
    Intel-based Macs: Resetting the System Management Controller (SMC)

  • Why does Local Folders not show up when I install Thunderbird on certain computers?

    I've installed Thunderbird on my computer and it looks normal with "Local Folders" showing up in the left pane. I didn't add an email account, I just installed Thunderbird and an add-on called ImportExport tool and left it with only Local Folders. But when I try to do the same thing and install it on someone else's computer to help them import an .mbox file, when I install Thunderbird on their computer, "Local Folders" is not there. The left pane is just completely blank. And it looks like I can't import an .mbox file without it being there. I tried installing it on another laptop too and the same thing happened with no Local Folders. Why is "Local Folders" not showing up for these other two computers?

    I circumvented the problem by copying the c:\users\username\appdata\local\thunderbird folder and the c:\users\username\appdata\roaming\thunderbird folder from my working PC to the nonworking computers, and Local Folders appeared in Thunderbird on those computers. It seems like these files aren't being generated properly on installation.
    I tried uninstalling Thunderbird from my working PC and reinstalling it again to see what would happen (after also deleting those two appdata folders so that fresh ones would be created), and this time Local Folders did not appear on my PC as well. I don't think I did anything different during installation either. So I'm not sure why the Local Folders are no longer being generated at installation.

  • Why does my blog not refresh itself when I open a new browser page?

    I add a new post to my blog. Sometimes it shows up in the browser. I close the browser, maybe....Today it has been about five days since I wrote a post. It still does not show up when I open my browser in Firefox. How do I refresh the browser? What should I do?

    Reload web page(s) and bypass the cache.
    * Press and hold Shift and left-click the Reload button.
    * Press "Ctrl + F5" or press "Ctrl + Shift + R" (Windows,Linux)
    * Press "Cmd + Shift + R" (MAC)
    Clear the cache and the cookies from sites that cause problems.
    "Clear the Cache":
    * Firefox > Preferences > Advanced > Network > Offline Storage (Cache): "Clear Now"
    "Remove Cookies" from sites causing problems:
    * Firefox > Preferences > Privacy > Cookies: "Show Cookies"

  • Why does a song not return to the same place when I close it?

    Recently, for some reason, when I have a song open and press 'my songs'  (which effectively closes the song) the song doesn't return to its usual location on the screen/folder. Instead it cues to the top left hand corner, and likewise with every other song, the same thing happens.
    It's only just started doing this which makes remembering what is where even more difficult.
    Any help much appreciated.

    You are welcome, Nick. Don't worry about the "é" - it will depend on your keyboard, if it is easy. On my keyboard I type first the accent ´ and then the e, and all is done

  • Why does the circuit not simulate correctly when i put two circuits in the same design.

    Hi,
    I have two circuits that i can simulate in their own designs and they work correctly but when i put the two circuits within the same design, one circuit does not work. I don't understand why this is happening. Could someone please explain why this is happening and how to solve it please?
    Below is the circuit i'm attempting to simulate. Each little circuit is what i've made previously in their own designs.
    When i simulate each circuit in it's own design i get the following waveforms.
    When i simulate both of the circuits together i get the following waveforms. The yellow and red signals have been attached to the right hand side of the 10nF caps. The signals have also been offset.
    Thanks for any help.

    By the Multisim circuit file do you mean the .ms12 file? If so, i've attached a copy of it here.
    Attachments:
    NchPch togther.ms12 ‏185 KB

  • Why does my ipad not work properly when charging

    when my ipad is plugged to charger it does not work properly  goes crazy

    Not sure what 'goes crazy' means but it most likely should not do that.  Try a reset... press the home and sleep/lock buttons until you see the Apple logo, ignoring the slider. Takes about 5-15 secs of button holding and you won't lose any data or settings.
    Also try it plugged into another outlet (on another circuit) and/or try another charger.

  • Why does my screensaver not kick in when I am using Firefox?

    I have a new pc, a pavilion using windows 7. I have set my screensaver to engage after 2 minutes and it does when I am using explorer, but it does not when I use firefox. Is there something in browser settings that I need to change? If so, how do I do that?

    Hard to say.. But...
    Try This...
    Close All Open Apps...  Perform a Reset... Try again...
    Reset  ( No Data will be Lost )
    Press and hold the Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears. Release the Buttons.
    http://support.apple.com/kb/ht1430
    If no joy...
    Connect to iTunes on the computer you usually Sync with and “ Restore “...
    http://support.apple.com/kb/HT1414

  • Why does my iPhone5s not show up when I connect it with iTunes on Window 8?

    I am trying to sync my iPhone5s with my iTunes on my windows 8 laptop and it does not recognize it.
    It does recognise it on a windows 7 laptop?
    where can I find the right insturctions on how to sync it?

    both my ipod touch 4th gen and my iPad Air is not detected., i have tried checking the USB cables,. and the Apple Mobile Device (Stop/Start Service from Computer MAnagement) in Windows 8.1 iTunes 11.1.5 is not detecting the devices,., i have check already for all updates,. nothing happens.,., but WIndows does detect the devices only itunes does not

  • WebI does not return failed when scheduling a report which only holds parti

    WebI does not return failed when scheduling a report which only holds partial results.
    We have scheduled reports which take some time to run. When they are scheduled they sometimes show successful even though the report only holds partial results. The only indication is when you open the report as webi report you see the warning that it holds partial results.
    When running the report manually, it works file.
    The issue is not in the no of rows in the universe settings because we this unselected. The issue is that it times out.
    The reason that it times out is that a lot of resources are used for loading and processing data when the report is scheduled. When running it manually, it works because at this time the serverload is less. the time in the universe is set to 10 min.
    The version we have is BOXIR2-SP4.
    Ok. Issue identified.
    The question is - why is the report successful when it holds partial results? If this is normal behavior, noone can really trust the scheduled reports, especially when you save it to excel and send it by mail.
    Is there a solution for this except increasing the allowed query time which would not solve the issu but only allow more reports to complete?
    Edited by: Karlgren Michael on Sep 17, 2009 1:22 PM

    Hi ,
    Currently this problem exists in XI R2. This feature will be part of thenext Service Pack i.e XI R2 SP6.
    This CER will be delivered from IDC Webi and BIP Platform as part of Jupiter Sp6.
    Problem Statement:
         Scheduled WebI Reports which are partially refreshed are distributed to the destinations for Users to View and make decisions. These users arenu2019t usually aware that these reports have u201CPARTIAL RESULTSu201D
    Recomended Solution:
        Allow the Schedule Creator / Modifier to set a parameter to stop the distribution of the u201CPARTIALLY REFRESHEDu201D WebI report.
    Thanks
    Salini

  • Why does the alarm not work when the iphone 4 is turned off

    why does the alarm not work when the iphone 4 for is  turned  off works fine when on most other phones work when off

    The only phone I've ever had that would turn on and sound the alarm is a Blackberry. So, I'd hardly say "most phones" have this function.

  • Why does i photo not launch when i click on icon in dock?

      Help why does i photo not launch when i click on icon in dock?

    The icons in the Dock are aliases. If iPhoto isn't launching from the dock the alias may be broken. What you can do is first test to if iPhoto is working by launching the app from the Applications folder. Once you have determined iPhoto is OK then remove the old Dock icon by holding it down and dragging it to the desktop, it will disappear in a puff of smoke. Then go to the Applications folder and drag the iPhoto icon to the Dock and test it.

Maybe you are looking for

  • New airport extreme not recognized by airport utility

    I've got a 2011 MBP. Right now I have an older Airport extreme up & working with my Time Warner cable modem. When I tried to connect my new 802.11n airport extreme, I couldn't get it to stop blinking amber. First the airport utility told me that I di

  • Saving PDF as 1.4 (Acrobat 5.x) after comments inserted?

    I have Adobe Acrobat Standard 9. I have printed an email, word file, etc to PDF ensuring using 1.4 in Distiller. I can open the file with Acrobat 5.0 However, if i make any editing, comments in the PDF file, when i save, it changes it to 1.6 therefor

  • Error on task manager BPEL 10.1.3.4.7 - oc4j

    Hi, I'm having problem with Task Manager on bpel 10.1.3.4.7 using oc4j, cluster environment. The following errors appears on error log intermittently, if I try to reprocess the same bpel process it works: ERROR> <segmentacao.collaxa.cube> <BaseCubeSe

  • HT4859 The photos have disappeared from my iPad

    Any ideas where all my photos have gone, the ones I transferred from my pc and the ones I have taken on the iPad?

  • Is there a active record class similar to the one in codeigniter for java

    I was wondering if there's a way to build sql statements in java similar to active record in codeigniter which is a PHP framework. Basically you call functions that builds your sql statements like so: db.from('users'); db.select('id'); db.where('name