Is that posible: return a value and AFTER THAT calculate next one?

I would like for better performance have a functionality to, first, return a value (prepared already), after that calculate a next one for next call.
Is that any way to perform it some how in PL/SQL?
After some time I have guess the next way:
  Have a table with current and next value
  On request read and return next.
  To update have a trigger on select to move the next value to the current and calculate the next-to-current into the 'next' column.
  Thus, I would need to have 'init'-procedure to set: table, if not exist; trigger, if not exist; set current (the first one) and next one into that table.
It just a plan; I am not sure if all doable.
But it seems kind of heavy.
Is it possible to have it simpler?

- I do not ask you to judg my task, processing, reasonability or an idea of sequence implementation.
That's the beauty of the forums - you get that extra help without having to ask!
Also I am not asking to help me in anything!
I do not have any assignment and do not need to anyone resolve my requirements!
Of course you are asking for help when you post on the forums; that is what they are here for.
And to get the best help you need to respond to the questions of the people that are trying to help you. You never responded to what both ramin and gaverill ask you above:
What is your objective? What problem are you trying to solve? Why is it not 'acceptable' to simply calculate the 'next' value when you need it?
For some reason you think using the DBMS_SCHEDULER is 'helpful' but you don't seem to realize that a job is going to be asynchronous to whatever else you are doing. Your code may need a value before the job is finished computing it.
Without knowing the PROBLEM you are trying to solve no one can help you find the most appropriate solution. And using a custom table to roll your own sequence generator is almost ALWAYS the wrong thing to do for both performance and scalability reasons.

Similar Messages

  • How to set default value and after that , use it as control

    Hello,
    Currently i am making motor driver from labview, and i am facing one problem.
    When i connect to my board via labview, it will relay last position to global variable. After that, i have to go to loop, where i can send back  modified position to my motor control board
    In short, i have to control number, but that number default value should be writtem by another function when i start vi.
    any ideas how to do it ?
    Solved!
    Go to Solution.

    Let me know if any clarification is needed
    Kudos are always welcome if you got solution to some extent.
    I need my difficulties because they are necessary to enjoy my success.
    --Ranjeet
    Attachments:
    VI.vi ‏13 KB

  • Help: I want to auto schedule a load using file watcher but it runs only once for the first time and after that it is not running at all

    Hi All,
    I am trying  to execute the below code as provided from one of the blogs. i am able to run the job only once based on a file watcher object(i.e. for very first time) and after that the job is not running at all and if  i schedule the job to run automatically based on interval of 10 or more minutes it is executing properly). Please let me know or guide me if i have missed any step or configuration.that is needed.
    Version of Oracle 11.2.0.1.0
    OS : Windows 7 Prof
    Given all the necessary privileges
    BEGIN
      DBMS_SCHEDULER.CREATE_CREDENTIAL(
         credential_name => 'cred',
         username        => 'XXXX',
         password        => 'XXXX');
    END;
    CREATE TABLE ZZZZ (WHEN timestamp, file_name varchar2(100),
       file_size number, processed char(1));
    CREATE OR REPLACE PROCEDURE YYYY
      (payload IN sys.scheduler_filewatcher_result) AS
    BEGIN
      INSERT INTO ZZZZ VALUES
         (payload.file_timestamp,
          payload.directory_path || '/' || payload.actual_file_name,
          payload.file_size,
          'N');
    END;
    BEGIN
      DBMS_SCHEDULER.CREATE_PROGRAM(
        program_name        => 'prog1',
        program_type        => 'stored_procedure',
        program_action      => 'YYYY',
        number_of_arguments => 1,
        enabled             => FALSE);
      DBMS_SCHEDULER.DEFINE_METADATA_ARGUMENT(
        program_name        => 'prog1',
        metadata_attribute  => 'event_message',
        argument_position   => 1);
      DBMS_SCHEDULER.ENABLE('prog1');
    END;
    BEGIN
      DBMS_SCHEDULER.CREATE_FILE_WATCHER(
        file_watcher_name => 'file_watcher1',
        directory_path    => 'D:\AAAA',
        file_name         => '*.txt',
        credential_name   => 'cred',
        destination       => NULL,
        enabled           => FALSE);
    END;
    BEGIN
      DBMS_SCHEDULER.CREATE_JOB(
        job_name        => 'job1',
        program_name    => 'prog1',
        queue_spec      => 'file_watcher1',
        auto_drop       => FALSE,
        enabled         => FALSE);
      DBMS_SCHEDULER.SET_ATTRIBUTE('job1','PARALLEL_INSTANCES',TRUE);
    END;
    EXEC DBMS_SCHEDULER.ENABLE('file_watcher1,job1');
    Regards,
    kumar.

    Please post a copy and paste of a complete run of a test case, similar to what I have shown below.
    SCOTT@orcl12c> SELECT banner FROM v$version
      2  /
    BANNER
    Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
    PL/SQL Release 12.1.0.1.0 - Production
    CORE    12.1.0.1.0    Production
    TNS for 64-bit Windows: Version 12.1.0.1.0 - Production
    NLSRTL Version 12.1.0.1.0 - Production
    5 rows selected.
    SCOTT@orcl12c> CONN / AS SYSDBA
    Connected.
    SYS@orcl12c> -- set file watcher interval to one minute:
    SYS@orcl12c> BEGIN
      2    DBMS_SCHEDULER.SET_ATTRIBUTE
      3       ('file_watcher_schedule',
      4        'repeat_interval',
      5        'freq=minutely; interval=1');
      6  END;
      7  /
    PL/SQL procedure successfully completed.
    SYS@orcl12c> CONNECT scott/tiger
    Connected.
    SCOTT@orcl12c> BEGIN
      2    -- create credential using operating system user and password (fill in your own):
      3    DBMS_SCHEDULER.CREATE_CREDENTIAL
      4       (credential_name     => 'cred',
      5        username          => '...',
      6        password          => '...');
      7  END;
      8  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> -- create table to insert results into:
    SCOTT@orcl12c> CREATE TABLE ZZZZ
      2    (WHEN      timestamp,
      3      file_name varchar2(100),
      4      file_size number,
      5      processed char(1))
      6  /
    Table created.
    SCOTT@orcl12c> -- create procedure to insert results:
    SCOTT@orcl12c> CREATE OR REPLACE PROCEDURE YYYY
      2    (payload IN sys.scheduler_filewatcher_result)
      3  AS
      4  BEGIN
      5    INSERT INTO ZZZZ VALUES
      6        (payload.file_timestamp,
      7         payload.directory_path || '/' || payload.actual_file_name,
      8         payload.file_size,
      9         'N');
    10  END;
    11  /
    Procedure created.
    SCOTT@orcl12c> -- create program, define metadata, and enable:
    SCOTT@orcl12c> BEGIN
      2    DBMS_SCHEDULER.CREATE_PROGRAM
      3       (program_name          => 'prog1',
      4        program_type          => 'stored_procedure',
      5        program_action      => 'YYYY',
      6        number_of_arguments => 1,
      7        enabled          => FALSE);
      8    DBMS_SCHEDULER.DEFINE_METADATA_ARGUMENT(
      9       program_name         => 'prog1',
    10       metadata_attribute  => 'event_message',
    11       argument_position   => 1);
    12    DBMS_SCHEDULER.ENABLE ('prog1');
    13  END;
    14  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> BEGIN
      2    -- create file watcher:
      3    DBMS_SCHEDULER.CREATE_FILE_WATCHER
      4       (file_watcher_name   => 'file_watcher1',
      5        directory_path      => 'c:\my_oracle_files',
      6        file_name          => 'f*.txt',
      7        credential_name     => 'cred',
      8        destination          => NULL,
      9        enabled          => FALSE);
    10  END;
    11  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> BEGIN
      2    -- create job:
      3    DBMS_SCHEDULER.CREATE_JOB
      4       (job_name          => 'job1',
      5        program_name          => 'prog1',
      6        queue_spec          => 'file_watcher1',
      7        auto_drop          => FALSE,
      8        enabled          => FALSE);
      9    -- set attributes:
    10    DBMS_SCHEDULER.SET_ATTRIBUTE ('job1', 'PARALLEL_INSTANCES', TRUE);
    11  END;
    12  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> -- enable:
    SCOTT@orcl12c> EXEC DBMS_SCHEDULER.enable ('file_watcher1, job1');
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> -- write file (file must not exist previously):
    SCOTT@orcl12c> CREATE OR REPLACE DIRECTORY upncommon_dir AS 'c:\my_oracle_files'
      2  /
    Directory created.
    SCOTT@orcl12c> declare
      2    filtyp utl_file.file_type;
      3  begin
      4    filtyp := utl_file.fopen ('UPNCOMMON_DIR', 'file1.txt', 'W', NULL);
      5    utl_file.put_line (filtyp, 'File has arrived ' || SYSTIMESTAMP, TRUE);
      6    utl_file.fclose (filtyp);
      7  end;
      8  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> -- wait long enough (may take more than one minute) for job to run:
    SCOTT@orcl12c> EXEC DBMS_LOCK.SLEEP (100)
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> -- check for results:
    SCOTT@orcl12c> SELECT * FROM zzzz
      2  /
    WHEN
    FILE_NAME
    FILE_SIZE P
    22-OCT-13 10.12.28.309000 PM
    c:\my_oracle_files/file1.txt
            57 N
    1 row selected.
    SCOTT@orcl12c> declare
      2    filtyp utl_file.file_type;
      3  begin
      4    filtyp := utl_file.fopen ('UPNCOMMON_DIR', 'file2.txt', 'W', NULL);
      5    utl_file.put_line (filtyp, 'File has arrived ' || SYSTIMESTAMP, TRUE);
      6    utl_file.fclose (filtyp);
      7  end;
      8  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> -- wait long enough (may take more than one minute) for job to run:
    SCOTT@orcl12c> EXEC DBMS_LOCK.SLEEP (100)
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> -- check for results:
    SCOTT@orcl12c> SELECT * FROM zzzz
      2  /
    WHEN
    FILE_NAME
    FILE_SIZE P
    22-OCT-13 10.12.28.309000 PM
    c:\my_oracle_files/file1.txt
            57 N
    22-OCT-13 10.14.08.580000 PM
    c:\my_oracle_files/file2.txt
            57 N
    2 rows selected.

  • SSAS- DAX expression : Is there any DAX function that can return multiple values ?

    Hi,
    Iam in search of a DAX function that can return multiple values as result. please find below scenario where i want to implement the same.
    I have three  Tables: Table A (typeid, Cost, Qty ) ,Table B (typeid, Cost, Qty ) , Table C ( typeid,Typename ) .
    Table A                                       Table B                               
    Table C
    type id  cost  Qty             type id   Cost    Qty                 
    typeid  typename
    1           100    100                3         300     
    300                  1           aa
    2           200    200                4          400    
    400                  2           bb
                                                                                             3           cc
                                                                                             4          
    dd 
    i have to club cost and Qty of two tables(four measures)  as two measures in the  UI report. There are more columns in these tables that restrict the  UNION of the tables.(for the sake
    of understanding , i have not mentioned the othr columns). In the UI report(Execl 2013-power pivot) iam plotting these measures against the
    Table C.Typeid. Hence the measures drill down against each 
    Table C. Typeid as shown below:
    Typeid  Table A.cost  Table A.Qty  TableB.cost  TableB.Qty                              
    1              100             100
    2              200             200
    3                                                    
    300             300      
    4                                                    
    400             400
    My requirement is to club these measures so that the report will be as below
    Type id  cost   Qty
    1          100    100
    2          200    200
    3         300     300
    4         400      400
    Since i cannot club these in model,as a work around, i created a calculated measure in excel(Analyze tab->Calculations->olap tools->calculated measure) with the condition as below:
    new cost = IIF (ISEMPTY(TableA.cost)="TRUE",TableB.cost,TableA.cost)
    new Qty = IIF(ISEMPTY(TableA.Qty)="TRUE",TableB.Qty,TableA.Qty) and dragged these new measures into the report. It was working fine as expected.
    But  this functionality of Creating calculatedmeasure in excel report is possible only in 2013 excel version.
    Now the requirement is to get the same result in 2010 excel. Can you please help me in implementing the same in 2010 excel? or any other alternative method to bring the columns in model itself. I tried to create a measure in table A with DAX expression as
    : new cost :=CALCULATE(SUM(Table B.cost),ISBLANK(TableA.cost)) -> but this will return only 1 result .i need Sum(Table A.cost) also if it is not blank.
    Thanks in advance

    You can use SUMX ( 'Table A', 'Table A'[Cost] + 'Table B'[cost] )
    However, if you install the latest version of Power Pivot in Excel 2010, it supports the ISEMPTY function, too.
    http://support.microsoft.com/kb/2954099/en-us
    Marco Russo http://www.sqlbi.com http://www.powerpivotworkshop.com http://sqlblog.com/blogs/marco_russo

  • Possible help I bought this iPhone, and after that I told him and lock

    Possible help I bought this iPhone, and after that I told him and lock, and I went to a companions did not know what should I do help me
    <Personal Information Edited by Host>

    If you are trying to activate an iPad or iPhone and it is asking for a previous owners Apple ID and password, you have encountered the Activation Lock. This is a security feature that prevents thieves from setting up and using a stolen or lost iPad or iPhone. You have no alternative. You must contact the previous owner to get permission to use the device. If you cannot contact the previous owner return the device to where you bought it and get a refund. You will never be able to activate the device and no one can help you do it.

  • Hello, i restored and updated my iphone 4 to the latest version of 5.1.1 and after that when i connect my mobile to i tunes all i see is a big rectangle and a apple logo on left and a small lock on right side please help me fix this problem.

    hello,
    i restored and updated my iphone 4 to the latest version of 5.1.1 and after that when i connect my mobile to i tunes all i see is a big rectangle and a apple logo on left and a small lock on right side please help me fix this problem.

    I sloved this issue by resting my phone from settings>general>reset>reset all settings...the problem will be fixed

  • Dear Apple Support,  Good day to you. This is to report the problem i encountered when i updated my Ipad mini to the new IOS 8.1..  After the update my Ipad restart and after that it appears a picture that need to connect to itunes and need  to resto

    Dear Apple Support,
    Good day to you.
    This is to report the problem i encountered when i updated my Ipad mini to the new IOS 8.1..
    After the update my Ipad restart and after that it appears a picture that need to connect to itunes and need  to restore. So i connect it to itunes and wait to restore my ipad mini because it is not opening.
    After restoring it my ipad is now opening and it is like new that i need to set up again.
    I set up again until i reach the apple id and password.
    I put my below apple ID and password to unlock my ipad but it didn't work. The message i receive is "the apple ID cannot be used to unlock this Ipad.
    What will I do? Please help.
    Thank you
    Sent from my iPhone
    Begin forwarded message:
    From: Apple <[email protected]***>
    Date: October 9, 2013 at 11:53:53 PM GMT+4
    To: ****
    Subject: Your Apple ID was used to sign in to iCloud and iMessage on an iPad mini 
    Dear Leslie J.,
    Your Apple ID was used to sign in to iCloud and iMessage on an iPad mini named “Leslie Joye's iPad”.
    If you have not recently set up an iPad with your Apple ID, then you should change your Apple ID password. Learn more.
    Apple Support
    <Email Edited By Host>

    1. It is never a good idea to include personal info like your email address or Apple ID in a post on an open forum.
    2. The email you received DOES NOT say your Apple ID cannot be used to unlock this iPad. The email informs you that your Apple ID was used to unlock an iPad. Fortunately the iPad is yours. The message confirms that. If your Apple ID was used to unlock an iPad that was not yours your would then know to change your password. Since the iPad is yours you do not need to change your password.
    Is your iPad working?

  • Hello everyone: I am going to buy a new ipad in Australia and after that I am going back to China. I am just wondering if I can use it in China without any problem? Do I have to unlock or something like that?

    Hello everyone: I am going to buy a new ipad in Australia and after that I am going back to China. I am just wondering if I can use it in China without any problem? Do I have to unlock or something like that?

    The iPad is not locked. Read the specifications.
    http://www.apple.com/ipad/specs/

  • My iphone 5s isn't turning on and its not charging. i have my legit charger that came with my phone and after 6 months it stopped working, i even have a charging case and that wont charge i. I tried cleaning it but still nothing! some please help

    A few days after i've updated to iOS 8.1.1 my iphone 5s died and isn't turning on and its not charging. i have my legit charger that came with my phone and after 6 months it stopped working, i even have a charging case and that wont charge it. I google searched the problem and tried cleaning the charging port but still nothing! some please help

    Please make a Genius Appointment and take it in for service.
    If your iPod Touch, iPhone, or iPad is Broken
    Apple does not fix iDevices. Instead, they exchange yours for a refurbished or new replacement depending upon the age of your device and refurbished inventories. On rare occasions when there are no longer refurbished units for your older model, they may replace it with the next newer model.
    ATTN: Beginning July 2013 Apple Stores are now equipped to do screen repairs/replacements in-house on iPhone 5 and 5C. In some cases while you wait. According to Apple this is the beginning of equipping Apple Stores with the resources needed to do most repairs for iPhones, iPads, and iPod Touches that would not require major replacements. Later in the year the services may be extended as Apple Stores become equipped and staffed with the proper repair expertise. So, if you need a screen repaired or a broken screen replaced or have your stuck Home button fixed, call your local Apple Store to see if they are now doing these in-house.
    You may take your device to an Apple retailer for help or you may call Customer Service and arrange to send your device to Apple:
    Apple Store Customer Service at 1-800-676-2775 or visit online Help for more information.
    To contact product and tech support: Contacting Apple for support and service - this includes international calling numbers.
    You will find respective repair costs in the appropriate link:
    iPod Service Support and Costs
    iPhone Service Support and Costs
    iPad Service Support and Costs
    There are third-party firms that do repairs on iDevices, and there are places where you can order parts to DIY if you feel up to the task:
    1. iResq or Google for others.
    2. Buy and replace screen yourself: iFixit

  • I had a trojan virus attack my computer and after that Firefox would no longer open up. I tried deleting it and re-installing it but that didn't work.

    When trying to re-install Firefox, it allows me to download it but when I hit run, it says its extracting and after that nothing else happens.

    Are you sure the virus is cleaned off your PC?
    Download and Install MalwareBytes Anti-Malware, run a full Scan. [http://www.malwarebytes.org/ http://www.malwarebytes.org/]
    Download and Run TDSSKiller [http://support.kaspersky.com/faq/?qid=208283363 http://support.kaspersky.com/faq/?qid=208283363]
    Download and Install Microsoft Security Essentials [http://windows.microsoft.com/en-US/windows/products/security-essentials http://windows.microsoft.com/en-US/windows/products/security-essentials] (not an official endorsement, but I personally recommend MSE as an awesome permanent anti-virus)
    Double check for all Windows Updates.
    Then, delete the firefox you downloaded, go to [http://www.getfirefox.com www.getfirefox.com], redownload and try to install Firefox again.

  • My ipod is disabled and i forgot the password and after that i plugged it in itunes and it still wont let me and the buttons arent working so i cant put it in recovery mode so what do i do!!

    my ipod is disabled and i forgot the password and after that i plugged it in itunes and it still wont let me and the buttons arent working so i cant put it in recovery mode so what do i do!!

    Use this program to place the iPod in recovery mode. Then restore.
    RecBoot: Easy Way to Put iPhone into Recovery Mode

  • I'm new to Mac and the program/all called Numbers. I'm trying to use both Average and small in the same formula. What's I'm trying to do is take 20 cells, find the 10 lowest numbers, then get the average and after that multiply it by .96

    I'm new to Mac and the program/all called Numbers. I'm trying to use both Average and small in the same formula. What's I'm trying to do is take 20 cells in a column,  find the 10 lowest numbers, then get the average and after that multiply it by .96  I used to use Excel and the formula worked fine in that. Here is my Formula
    =(average(small(H201:H220,{1,2,3,4,5,6,7,8,9,10})))*.96
    This formula worked in Excel and when I converted my spreadsheet over to Numbers, this formula no longer works.
    The best that I have been able to do so far is use small in 10 different cells, then get the average of the 10 cells and finally multiply that average by .96  So instead of using 1 cell, I'm using 12 cells to get my answer.
    This is a formula that I will be using all the time. The next cell would be =(average(small(H202:H221,{1,2,3,4,5,6,7,8,9,10})))*.96
    Hoping I explain myself well enough and that someone can help me.
    Thanks

    You can still do it in one cell but it will be more unruly than the Excel array formula.
    =average(small(H201:H220,1),small(H201:H220,2),small(H201:H220,3),...,small(H201:H220,10))*0.96
    where you would, of course, replace the "..." with the remaining six SMALL functions.

  • I have an iphone 5s and my phone was working perfectly fine then it turn into a blue screen and after that i tried to restore it but when i do the phone does half of the steps and then it turns into a blue screen and it doesnt work again what can i do?

    i have an iphone 5s and my phone was working perfectly fine then it turn into a blue screen and after that i tried to restore it but when i do the phone does half of the steps and then it turns into a blue screen and it doesnt work again what can i do?

    The Basic Troubleshooting Steps are:
    Restart... Reset... Restore from Backup...  Restore as New...
    Malvinfromny wrote:
    ... i tried to restore it but when i do the phone does half of the steps and then it turns into a blue screen and it doesnt work again what can i do?
    If you try all these Steps and you still have issues... Then a Visit to an Apple Store or AASP (Authorized Apple Service Provider) is the Next Step... Be sure to make an appointment first...

  • Have just installed Mavericks and restarted the MacBook Pro. That was 3 hours ago and after logging in, I got my wallpaper and dock, but none of my desktop icons, just the spinning coloured wheel. It's been like that for 2 hours. Is this normal? What shou

    Have just installed Mavericks and restarted the MacBook Pro. That was 3 hours ago and after logging in, I got my wallpaper and dock, but none of my desktop icons, just the spinning coloured wheel. It's been like that for 2 hours. Is this normal? What should I do, please?
    I tried holding the on/off switch down to make it shut down, but when I turned it back on again, the same thing happened and none of the keys etc makes any difference.
    HELP!!!! Please.

    No, what you're experiencing is not normal.
    Try booting whilst holding down the Shift key - this will allow you to boot into Safe Mode, disabling third-party kernel extensions, etc. Your Mac will be slow to boot and will operate sluggishly. That's normal. If you can get in using Safe Mode then you have some start-up item that doesn't play well with Mavericks.
    Call back,
    Clinton

  • HT1338 Facebook doesn't open in safari on my MacBook Pro, why? Sometimes it opens and aftersome time just hang on and after that doesn't open at all.

    Facebook doesn't open in safari on my MacBook Pro, why? Sometimes it opens and aftersome time just hang on and after that doesn't open at all.

    There seems to be a few bugs with iCloud Mail at times, so send Apple feedback. They won't answer, but at least will know there is a problem. If enough people send feedback, it may get the problem solved sooner.
    Feedback
    Apple support article, but I don't think it really addresses your problem.
    iCloud - Mail Troubleshooting

Maybe you are looking for

  • [SOLVED] HDMI output not working

    I just bought myself a home theater system but can't get my laptop to connect to the reciever. My laptop is an Asus UX31E with integrated HD 3000 graphics. When I connect a HDMI cable to the reciever (Pioneer VSX-527) it doesn't even detect my laptop

  • Javax.servlet.jsp.JspException: java.lang.NullPointerException

    hi, I try to view my presentation in jsp page.I use oracle jdeveloper 9.2.0.4 and bibeans 9.2.0.4 and once 1 month ago I did this taks (I view a presentation from bibdemo in jsp file) now I try to view my own presentation in jsp but I recieve error m

  • Change my Host Name in Solais 10

    Please, when I run smc(Solaris Management Console) I can see in System Information, that my Host Name is unknown. How can I change that?

  • ITunes repeatedly looses file locations of some songs

    I recently had to move my music files to a new external hard drive. After getting everything moved over and changing the settings, I can now listen to import most music just fine. However, each time I try to sink my iPod, the program manages to loose

  • Is Adobe ever going to do a flash player for Windows 7 64 bit IE ?

    I've had my Win 7 64 bit laptop over 6 months and still no sign of compatible flash player for the IE 64 bit. Is there ever likely to be one ?