Problem with using ALL_SEQUENCES in a function

Hi all. I want to create a function that returns the current value of an Oracle sequence. My function looks like this:
function getSequenceCurrentValue(sequenceName varchar2) return integer is
sequenceLastNumber integer;
begin
select tb_all_sequences.LAST_NUMBER into sequenceLastNumber
from sys.ALL_SEQUENCES tb_all_sequences
where tb_all_sequences.SEQUENCE_NAME = sequenceName;
return sequenceLastNumber;
end;
For example there are two users in my database: User1 and User2.
User1 owns Seq11 and Seq12
User2 owns Seq21 and Seq22.
User1 has the privilege to access Seq21 and Seq22.
But when I try to use my function to get the last number of Seq21 or Seq22 when logged as User1 the function returns NULL.
When I try to get the last number of Seq11 or Seq12 when logged as User1 the function works.
Does anyone have any ideas why the function does not work with the sequences which are not owned by the logged user? Oracle docs say ALL_SEQUENCES 'describes all sequences accessible to the user'.

With direct privileges it is not a problem:
SQL> create user user1 identified by user1
  2  /
Gebruiker is aangemaakt.
SQL> grant create session, create procedure, create sequence to user1
  2  /
Toekennen is geslaagd.
SQL> grant select on all_sequences to user1
  2  /
Toekennen is geslaagd.
SQL> create user user2 identified by user2
  2  /
Gebruiker is aangemaakt.
SQL> grant create session, create sequence to user2
  2  /
Toekennen is geslaagd.
SQL> conn user1/user1
Verbonden.
SQL> create function getSequenceCurrentValue(sequenceName varchar2) return integer
  2  is
  3    sequenceLastNumber integer;
  4  begin
  5    select tb_all_sequences.LAST_NUMBER into sequenceLastNumber
  6    from sys.ALL_SEQUENCES tb_all_sequences
  7    where tb_all_sequences.SEQUENCE_NAME = sequenceName;
  8    return sequenceLastNumber;
  9  end;
10  /
Functie is aangemaakt.
SQL> create sequence seq11 start with 1 increment by 1 nocache
  2  /
Reeks is aangemaakt.
SQL> create sequence seq12 start with 1 increment by 1 nocache
  2  /
Reeks is aangemaakt.
SQL> conn user2/user2
Verbonden.
SQL> create sequence seq21 start with 1 increment by 1 nocache
  2  /
Reeks is aangemaakt.
SQL> create sequence seq22 start with 1 increment by 1 nocache
  2  /
Reeks is aangemaakt.
SQL> grant select on seq21 to user1
  2  /
Toekennen is geslaagd.
SQL> grant select on seq22 to user1
  2  /
Toekennen is geslaagd.
SQL> conn user1/user1
Verbonden.
SQL> select getsequencecurrentvalue('SEQ11') seq11
  2       , getsequencecurrentvalue('SEQ12') seq12
  3       , getsequencecurrentvalue('SEQ21') seq21
  4       , getsequencecurrentvalue('SEQ22') seq22
  5    from dual
  6  /
     SEQ11      SEQ12      SEQ21      SEQ22
         1          1          1          1
1 rij is geselecteerd.Regards,
Rob.

Similar Messages

  • Problem with "&#34" using PL/SQL extract function ( XMLTYPE)

    Hi,
    When I use extract function (PL/SQL), it does not transform well "&#34". Insted of returning ' " ' , it returns ' &quot '.
    I know this works changing the code replacing xml.extract for SELECT extractvalue(xml,'//A/text()') into v from dual;
    But Is there another way to do this using PL/SQL? any patch, option..?
    Regards

    Hi,
    cursor proct is select * from proc22;
    cursor proct5 is select *from proc24;
    fetch proct into proctval;
    fetch proct5 into proctval5;
    if proct.symbol=proct5.symbolThat's strange to join two tables like this. You will have chance if you enter in your if condition.
    Why not create only one cursor with this join condition on the two tables ?
    re5:=re5/proctval.previousprice5;Furthermore, what do you make with r5 variable ? It seems nothing to do. Your proc does no much job.
    What do you want to achieve exactly ?
    Nicolas.

  • I have two Iphones with different email addresses sharing one Apple ID. Will that cause problems with using messaging and FaceTime?

    I have two Iphones 5 with different email addresses sharing one Apple ID account.Both are using IOS 8.
    I would like to set up a new Apple Id for one of the phones and remove it from the old account.
    If I do that, can I move all of the purchased apps and songs to the new Apple account?
    Also, will sharing one Apple ID account with two devices cause problems with using messaging and FaceTime?

    Sharing an iCloud account between two devices can be done without causing issues with iMessage and FaceTime, just go into Settings for each of these functions and designate separate points of contact (i.e. phone number only, or phone number and unique email address).  While that works, you'll then face the problem where a phone call to one iPhone will ring both if on the same Wi-Fi network -- but again, that can be avoided by changing each phone's settings.
    Rather than do all that, don't fight it -- use separate IDs for iCloud.  You can still use a common ID for iTunes purchases (the ID for purchases and iCloud do not have to be the same) or you can use Family Sharing to share purchases from a primary Apple account.

  • Chart - problem with realize one of the function under CR XI

    Post Author: mrowa
    CA Forum: Charts and Graphs
    Hello,
    I have
    problem with realize one of the function under CR XI. I would be persuade if
    any of us would like to help me.
    1)   
    1) From
    database (basically from one table), I take data to make report. Each of record
    have appropriate fields:
    dteData
    intYear
    intMonth
    intDate
    2)   
    2) I
    want to realized comparison data from two or more periods of time on one chart
    and in one table. For easily explanation I will describe problem on two
    periods.For instance, user want to display and compare
    on chart date (type monthly -sum data of each month) from 2007.02 u2013 2007.05
    with date from 2006.03 u2013 2006.06. So we compare month 2007.02 with 2006.03;
    2007.03 with 2006.04; 2007.04 with 2006.05; 2007.05 with 2006.06
    On char I would like to display bars with comparison
    of months.
    Problem is that I donu2019t know how to write
    something similar. I can use one period without any problems, but two and mores
    I canu2019t realized.
    Detail description:
    I passed
    two parameters two report:
    {?from}, {?to} u2013for first period
    {?offset}, it means {?from}+{?offset},
    {?to}+{?offset}  - for second period
    On axis Y I have Sum(intDate);On
    X (year + month). But on each value x( example 20007.02) I need to have
    two values (bars). Value for standard period and offset.
    For example for x=2007.02, I need
    two bars one equal 2007.02 and second with offset u2013 2006.03
    Movement to next value (bar) is
    persuade by fields {data.rok}&{data.month} first or second period. This is
    combination of two elements year&month defined under Formula. Problem
    persist in that both period has different year.month and here problem starts once
    again. I donu2019t know how to solve it. I have found out one solution but it
    limits user only for two periods (I want to compare more).
    My idea for compare only two
    periods:
    I make one query in CR for one
    period and second query for second period.
    Firs query:
    "SELECT 
           year ,
          month
    Second query
    "SELECT 
           year + FLOOR({month + offset} % 13),
          {month + offset} % 13
    Then in CR I connect two periods and
    make u201Ctableu201D (results of queries) with JOIN on fields year and month.
    This solution is not functional,
    because I need to make reports for days and hours as well. In this solution I
    canu2019t use (%31), because not all months has 31 days.
    I use CR in WEB app made in Visual
    Studio 2005. Maybe from aspx we can manipulate with date to get exact solution,
    and solve problem with SELECT.
    Hope my description clearly
    describe problem and someone will be able to help me. I would be thankful.

    I have had similar problem before.
    Because I had too many data, the legend would not display all the data. Also the chart would not display all the data. But I was able to find a work around.
    In your case, Right click on the Legend text and click on Format Legend Entry.
    Change the font of the legend to 4 (which is the minimum). This may work.
    If you are also having problem with data labels, you could change the font size of the data labels.
    Hope this helps.
    Thank you.

  • Problem with the MVMapView.print(printMapDiv,) function.

    Hello,
    I have a problem with the MVMapView.print(printMapDiv,) function.
    My FOIs are displayed correct on the screen but on the printed letter
    the stroke(border) color and the labels of a circle are not displayed.
    the fois have a custom style:
    var xmlDef = '<svg width="1in" height="1in">'+
    '<g class="marker" '+
    'style="width:40;height:40;stroke:0xff0000;fill:0x00ff00;stroke-width:1.5">'+
    '<circle r="20"/>'+
    '</g>'+
    '</svg>';
    markerStyle = new MVXMLStyle("my_vector_icon_" + i + '_' + j, xmlDef)
    and are created like this:
    v_result = new MVFOI(p_geofeature.foiId, p_geofeature.foiGeomertyObject, markerStyle, null, 30, 30);
    v_result.setHTMLElement('1',0,0);
    Browser: I can see the map with a green circle, a red border and '1' as a label on
    top of the Circle.
    Printed Letter: I see the map with the green circle but no red border Color and no label.
    The implmentation of the printing function uses the same techique like the "Oracle Maps Tutorial"
    It is a javascript function called through a href link:
    function mapPrint()
    var a=document.getElementById("printmap");
    global_gdi.mapviewer.mapview.print(a);
    Version is Ver11_1_1_5_B110527
    Does anbody know how to print the map properly including the contents of the
    MVFOI class set trough setHTMLElement function?
    Greetings
    Andre

    Thanks for your reply but it is not working and i can prove that.
    I have a small example based on the mapviewer print tutorial. To run it you need a
    mapviewer installation and copy the text into a html file. In the browser you can see
    a green point with a red border and red label text on a map.
    If you use the print button everything except the label text will be printed.
    I think this is a mapviewer css-api bug.
    <html>
    <head>
    <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <style type="text/css">
    @media screen
    .noscreen {display: none;}
    @media print
    .noprint{display: none;}
    </style>
    <script language=&quot;Javascript&quot; src=&quot;/mapviewer/fsmc/jslib/oraclemaps.js&quot;></script>
    <script language=javascript>
    var mapview;
    var baseURL = &quot;http://&quot;+document.location.host+&quot;/mapviewer&quot;;
    function showMap()
    mapview = new MVMapView(document.getElementById(&quot;map&quot;), baseURL);
    mapview.addMapTileLayer(new MVMapTileLayer(&quot;mvdemo.demo_map&quot;));
    mapview.setCenter(MVSdoGeometry.createPoint(-122.45, 37.6706,8307));
    mapview.setZoomLevel(4);
    mapview.display();
    //adds custom foi with label
    var xmlDef = '<svg width=&quot;1in&quot; height=&quot;1in&quot;>'+
    '<g class=&quot;marker&quot; '+
    'style=&quot;width:40;height:40;font-family:sans-serif;font-size:20pt;stroke:0xff0000;fill:0x00ff00;stroke-width:1.5&quot;>'+
    '<circle r=&quot;20&quot;/>'+
    '</g>'+
    '</svg>';
    var markerStyle = new MVXMLStyle(&quot;my_vector_icon_&quot;, xmlDef);
    mpoint = MVSdoGeometry.createPoint(-122.30, 37.73,8307);
    var v_result = new MVFOI(&quot;11&quot;, mpoint, markerStyle, null, 60, 60);
    v_result.setHTMLElement('test label',0,0);
    mapview.addFOI(v_result);
    function mapPrint()
    var a=document.getElementById(&quot;printmap&quot;);
    mapview.print(a);
    </script>
    </head>
    <body onload=javascript:showMap()>
    &lt;div id=&quot;map&quot; style=&quot;position:absolute;top:50px; left:10px; width:600px; height:450px;border:0px&quot;>&lt;/div>
    &lt;div id=&quot;printmap&quot; class=&quot;noscreen&quot;>&lt;/div>
    &lt;p>Please click &lt;a href=&quot;javascript:mapPrint()&quot;>here&lt;/a> to print map&lt;/p>
    </body>
    </html>
    Edited by: user12005064 on 27.02.2012 02:37

  • I am going to buy unlocked iphone 5.. i will be going to india nxt months and will stay there for a while... so my question is will i get warrenty in india.. and will there be any problem with using indian sims..?? thnx for the help..

    i am going to buy unlocked iphone 5.. i will be going to india nxt months and will stay there for a while... so my question is will i get warrenty in india.. and will there be any problem with using indian sims..?? thnx for the help..

    The warranty for the iPhone is not and has never been International.
    Warranty and support are ONLY valid in the country of origin.  The only exception is the EU where the entire EU is treated as one country.
    If the device will be used in India, buy it in India.
    An unlocked iPhone will work on any supported GSM carrier world wide.  The LTE portion of a US purchased, unlocked iPhone is unlikely to work outside North America as it does not support the appropriate bands used in other countries.

  • I purchased Adobe Creative Suite C2 and have been using it for years on the same computer no problem with using it. Recently upon opening Photoshop I received a pop up window saying due to Adobe Software security we need you to activate your CS2 software.

    I purchased Adobe Creative Suite C2 and have been using it for years on the same computer without any problems with using it. Recently upon opening Photoshop I received a pop up window saying due to Adobe Software security we need you to activate your CS2 software. I tried, phone activation, web activation, nothing is working. I have the serial number and my Adobe account information. Any suggestions?

    Error: Activation Server Unavailable | CS2, Acrobat 7, Audition 3
    Mylenium

  • Problem with use of COM+ Transaction and DB Transaction

    Problem with use of COM+ Transaction and DB Transaction
    We build a Web site that use sometime COM+ Transaction and sometime DB
    Transaction. If we use a COM+ Transaction and a few seconds later we try to use
    a Database Transaction (OracleConnection.BeginTransaction), we get the error
    Connection is already part of a local or a distributed transaction
    Of course the error does not produce everytime; it takes some try before we get
    the problem. And of course, if i use pooling=false on the connection string,
    the problem does not appear.
    i run the Web page
    and push the COM+ Transaction and DB Transaction one after the other for some
    times and the problem should appear.
    Environment: Windows server 2003, .Net Framework 1.1, ODP.Net 9.2.0.401,
    Database Server 9.2.0.4

    > Why in form builder can't I...
    Is this happening at runtime or at buildtime? You'll need to provide more info on what you are actually doing that's causing the problem.
    Regards,
    Robin Zimmermann
    Forms Product Management

  • After upgraded ios6 i got problem with whatapp. "last seen" function is not working

    HI eveyone
    after upgraded ios6 i got problem with whatapp. "last seen" function is not working .. it's doest show last seen who enter the chat . is anyone have the same problem .. i even restore and reinstall to my ph but it's  not work .. if someone know how to fix it, plz tell me how to do .. thanks

    Also, when I check this post several times a day, I always see warning 'Connection is untrust'. If I close browser and reopen immediately everything is ok.

  • Problems with use cases in JDeveloper 11.1.1.1.0

    Use cases made with JDeveloper 11.1.1.0.2 can not be used and edited in JDeveloper 11.1.1.1.0.
    Same problems with Use Case Diagrams.
    And it seems to be impossible to create new use cases in JDeveloper 11.1.1.1.0.
    What are the differences between 11.1.1.0.2 and 11.1.1.1.0 if you look at use cases??

    In JDeveloper 11.1.1.0.2 each use case has one file with the folllowing name: *.xhtml_usc.
    In JDeveloper 11.1.1.1.0 each use case has two files with a names like *.xhtml_usc and *.uml_usc (after standard migration with JDeveloper). I can still edit the *.xhtml_usc files, but I have no idea what to do with the *.uml_usc files. I can only open a Property-editor, but the properties I see have no relation with the text I used in my original use cases . New use cases only have a *.uml_usc file and a Property-editor. In javadoc the new use case does not appear.
    My question is: why do I have two different use case files in JDeveloper 11.1.1.0 and how can I use the Property editor??

  • AxWindowsMediaPlayer problem with using subtitle sami.file in winform

    Hello every body
    I have a problem with using sami caption in axWindowsMediaPlayer;
    how can I use it?
    I used
    axWindowsMediaPlayer1.closedCaption.SAMIFileName="FileNameAddress";
    and
    axWindowsMediaPlayer1.ShowPropertyPages();//and select sami file
    but in both ways the subtitle is not shown in my axWindowsMediaPlayer1 control;
    please help me for solving this problem

    Hi ,
    As i know the Synchronized Accessible Media Interchange (SAMI) file must use an .smi or .sami file name extension.
    set the smi-file direclty like following
    AxWindowsMediaPlayer.closedCaption.SAMIFileName = "subtitles.smi";
    Please also refer here
    for more details.
    Follow the steps below for your Windows Media Player to display captions and subtitles.
    http://support.3playmedia.com/entries/21934486-windows-media-files-windows-media-player-settings
    Related thread, please note the Style secttion.
    http://answers.microsoft.com/en-us/windows/forum/windows_7-pictures/wmp-12-doesnt-play-sami-files-closed-captions/96fe98b7-1cdf-41f5-aa9e-a4e55fd07c0a
    In addition, Could you please provide your smi or sami file and full code? It could be better to help us do some test on my side.
    Have a nice day!
    Kristin
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • I am having problem with using the Basic brush definition

    I am having problem with using the Basic brush definition. When I try to click on it will not allow me to use it and will automatically use the 5 pt. oval brush definition. The only way I can use the basic brush is after I have already drawn something and then I have to click on the stroke and then press basic. This is incredibly annoying and if anyone could help I would greatly appreciate it. (I have Adobe CS6)

    for whatever reason, the basic 'brush' you see in the brushes palette effectively means removing any brush from a path. to draw with the brush tool you need a brush defined. in your case the last one selected being the 5 pt oval one.

  • I am having problem with using my Basic brush definition

    I am having problem with using the Basic brush definition. When I try to click on it will not allow me to use it and will automatically use the 5 pt. oval brush definition. The only way I can use the basic brush is after I have already drawn something and then I have to click on the stroke and then press basic. This is incredibly annoying and if anyone could help I would greatly appreciate it. (I have Adobe CS6)

    Basic is not a brush, only a starting point for you to make a brush. Load the real brush you want before beginning to draw.

  • In FF4.0.1 problem with using HTML creator in WebCT. WHY? Not a problem in FF4.0.0

    In FF4.0.1 problem with using HTML creator in WebCT. WHY? Not a problem in FF4.0.0

    Hi Shane,
    I passed through all the described problems in the list, and after doing several tests the error that you described is always present if the "jpcsclite_en_US.properties" is not present in the same place of the "jpcsclite.properties". I really don't know the reason, I just copied and pasted the same file, renamed the copy and the error was gone... though both of them include the line where the .dll is found!
    That's how it worked for me, but if anybody knows how it works without that dirty trick, it would be good.
    Regards,
    Leandro
    PS: Just in case that somebody is using the version JCSDK3.0, I did not find the .dll in that version, but in the JCSDK2.2.2 *(:-S)*

  • I have a problem with using MacBook Pro as wifi router when connected to ethernet

    I have a problem with using MacBook Pro as wifi router when connected to ethernet. The Airport icon changes to show a laptop inside, my iPad shows connected (I think) but Safari will not operate. I tried pinging my iPad, it seems to see the iPad, but no connection to Safari or to other apps such as Good on the iPad. I have read many posting and tried repeatedly via Sharing in Systems Preferences, but no luck. Suggestions to fix, or is this a Lion problem?

    Usually this is a problem related to the domain name server address. If you open Network preferences, select your Ethernet port then click on the Advanced button then on the DNS tab. You will likely see an entry like 10.0.1.1 already listed. Click on the Add [-] button and enter 208.67.222.222 then click on the OK button and then on the Apply button.  See if this helps.
    if it does not help then repeat the above but with the Airport port.

Maybe you are looking for

  • How to tell if new MacBook Air is a lemon?

    I purchased a MacBook air two weeks ago and have been noticing problems with it since then. I'd like to list them below and solicit your feedback as to whether this is pointing to a larger problem I should seek Apple Care help for, or if this may be

  • Satellite A350-07C - How to transfer movies from camcorder?

    Hi Everyone. Just wanted to know if anyone knows how I can upload movies from my Sony DCR-TRV19E that has USB and DV iLink slots into my Toshiba Satellite A350/07C? My understanding is that Sony does not support USB drivers for Windows Vista and 7 (a

  • How to burn Bootcamp Support software on DVD?

    Hello guys i just downloaded Windows via Bootcamp but the only problem is i need Bootcamp support software in order to get things going. I can't even connect to internet right now. I know i can burn Bootcamp Support software on an external drive; but

  • My auto suggestion bar disappeared - how do I get it back?

    My auto suggestion bar on my phone when texting - how do I get the suggestion bar back?  It was an ios8 feature and I loved it.

  • Database restore/recovery questions...

    HI I am somewhat new to the recovery process and I have just installed a new 2 node cluster on linux itanium and I have created a testdb in ASM. I have backup up the new testdb using rman with a full online backup and including control file. We are n