CTE not allowed inside a stored proc/function?

Using Oracle 11 g 2. This relaxed in 12 c?

Agreed. If you write the complete SQL statement, it works very well (I assumed SELECT INTO...). Share the rest of your service if you want help with it.

Also, you can't assign a value to a function parameter that you tried on line 9.

CREATE OR REPLACE FUNCTION fn_nextprev_workdate(
    p_date1 DATE,
    p_num   NUMBER)
  RETURN DATE
IS
  v_num  NUMBER;
  v_date DATE;
BEGIN
  --p_num := 1;
  IF p_num < 0 THEN
    v_num := -1;
  END IF;
    WITH t AS
      (SELECT COUNT (
        CASE
          WHEN TO_CHAR (p_date1 + ROWNUM*v_num, 'fmDY') IN ('SAT', 'SUN')
          THEN 1
        END) cnt
      FROM DUAL
        CONNECT BY ROWNUM <= ABS(p_num)
      )
      SELECT cnt INTO v_num FROM t;
    RETURN sysdate;
  END fn_nextprev_workdate;
/

Tags: Database

Similar Questions

  • niUSRP Signal.vi set not allowed inside loops?

    It seems that niUSRP than signal.VI set is not allowed in loops. After the decision of the VI, I get this message:

    niUSRP configure Signal.vi, this attribute cannot be changed while the driver is in the operating state.

    Is there a way to change the frequency of the carrier, while the driver is running? With the help of property Node.vi of niUSRP to set a new frequency within a loop is also not working. My goal is to create with the USRP to frequency hopping.

    Hi YYY.

    Thanks for your VI, including in the post.  I was able to download it and reproduce what you see.  There are a few things that need to be changed in order to get this to work.

    First of all, you don't need to have the niUSRP function to configure Signal.vi inside your time loop.  You can put this outside the loop and a property node allows you to change the frequency with a property node.  You already have the property node in your code, you just need to change it to write instead of read.  There is an example that will do just that, if you just want to use it instead of modify your code too much.  It's called niUSRP EX Tx continuous Async Reconfig on the Fly.vi.

    Then, the reason why you are not able to go at the rate of 1 ms/s IQ with the code you have is because you're trying to read and write the frequency during each iteration of the loop.  Because of the time to query the hardware, set the frequency and read the return frequency, the I was able to get the maximum rate of IQ was around 500kS/s.  This is due to a combination of hardware and driver limitations.  Even with the example above uses the property instead of the function of the configuration node, if I put in an indicator to look at frequency I can't use a faster speed of the IQ.

    Try to change the property node and the withdrawal of this indicator, you should have a lot more success.  Let me know if this does not work for you or if you have any other questions, I'd be happy to help you.

  • Code error 0xc004e003, and Vista Home Edition Premium is not allowed.

    Original title: my windows vista family premium is now show a message that it is not allowed, after 4 years of functioning.

    I also have an OxCOO4E003 code. Can you advise what happened? The software is legal, he came with the ACER PC at the time of purchase. Thank you.

    Hi JohnRuru,

    1. have you made a recent software or hardware changes to the system?

    2. are you able to boot to the desktop?

    You can read the following article and check if it helps:

    Error message when you try to activate a copy of Windows Vista: "the Software Licensing Service reported that license evaluation failed: 0xC004E003".

  • Transaction validation error in Stored Proc call - prev solns does not

    Hi all

    Our process calls a DB adapter to retrieve the answer from the table to our application via a call to stored procedure, but in the face of the slot issue. Its a synchronous process. The stored procedure is present inside the package and call the stored procedure using this Package.

    What we did is created a DB of type XA data source and tried to call the stored Proc but it appeared a problem "ORA-24777: the use of the non-migratable unauthorized link database ' and therefore, according to this thread DB links in stored proc call into the adapter DB 11 G SOA , we have changed the type of non - XA data source.

    While we do this, we could see that stored procedure is called and the answer is not in the payload to answer within the track of the flow. But the instance is get failed and the error is "error committing transaction:; nested exception is: javax.transaction.xa.XAException: JDBC driver does not support the XA, so may not be a participant in the validation in two phases. To force this participation, set the attribute GlobalTransactionsProtocol (recommended) LoggingLastResource or EmulateTwoPhaseCommit for the Data Source. »

    We have tried properties to support overall transaction as imitate a validation phase, two phase commit and logging last resource but error remains the same.

    Database from where we get the answer is a version of "Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production". The link of database error is due even if we connect to the Oracle database?

    Please could you tell me solutions for this problem.

    Thanks in advance.

    You use a Non - XA because it means (among others) that the issue of validation can be handle by the DB as well.
    The property to imitate two Phase imitating the transaction XA in this way, it allows you to manage a transaction local db.
    You can stay with XA connection, but then you have to use 'pragma AUTONOMOUS_TRANSACTION' in your procedure.

    Enter the following link to find the explanation on your questions:
    http://docs.Oracle.com/CD/E15523_01/integration.1111/e10231/adptr_db.htm#BGBIHCIJ

    Arik

  • I keep getting these messages that do not allow to use a file. What should I change to have privileges for all functions?

    Original title: administrator Win7

    I have win7 and IE11 running on a HP 8540p.  I'm the only person authorized to use the laptop - I am the administrator.

    I keep getting these messages that do not allow to use a file.  What should I change to have privileges for all functions?

    The second file is not cooperating and was not deleted.

    "Not cooperating" can mean many different things. A real verbatim error message would be more useful. In the case of locked files, it is often possible to remove safe mode.

  • Windows Snap function does not work inside a Setup dual monitor.

    I have Windows 7 Home Premium x 64 fully updated.  So far, it's great. But I have two monitors, 1440 x 900 primary and secondary 1280 x 1024 with the secondary monitor on the right of the main screen. When I try to 'break' a window on the edge of each monitor located next to the other monitor, nothing happens.  I was wondering if it was a typical problem people have seen or if it was just me and if there is no way to do work or if there was a patch for it. (A built-in feature of Google chrome "fit" allows inside monitors). Thanks for your help!

    Hello

    The action which engages a window on the side of a monitor, when you drag a window, is when the cursor comes in contact with the last row of pixels on the edge of the screen. Since there is no physical "edge" where monitors meet on a dual monitor configuration by dragging a window to that location does not work.

    You can always break a window inside edge on a double configuration monitor using the keyboard.

    = Wink left arrow Windows logo key + left key
    = Wink right arrow Windows logo key + right key

    I hope this helps.

    Thank you for using Windows 7 Ronnie Vernon MVP

  • A SQL server management studio 2012 error: PERCENTILE_DISC function is not allowed in the current compatibility mode. It can only in mode 110 or higher.

    Our company just upgraded to SQL Server Management Studio 2012 and it has been very useful because I needed to use the percentile for the code I wrote. As a first step, the function did not work because I set the compatibility mode 110 level. After that I did, the function worked. However, now it does not work yet, and I get the same error:

    The PERCENTILE_DISC function is not allowed in the current compatibility mode. It can only in mode 110 or higher.

    I went to the properties of database section, then options and noticed that the compatibility mode has not changed, it is set to "SQL Server 2012 (110). I even used the following code to see if that would help at all even if the compatibility mode is already on this mode:

    ALTER DATABASE Analytics
    SET COMPATIBILITY_LEVEL = 110 
    

    Someone already had this problem or knows if I need to change something in the properties of database for this function work? Is this just a bug in the new version?

    Hello

    I suggest you post this question in the SQL Server 2012 TechNet Forums: http://social.technet.microsoft.com/Forums/en-us/category/sqlserver

    Thank you.

  • Ezvpn distance, not allowed to exempt NAT inside

    I'm a bit puzzled as to why I'm not allowed to have this rule of NAT exemption in place while the distance EZVPN is enabled.

    Here's my topology:

    I created a DHCP pool reserve based on the MAC address of my laptop; He received the reservation address.  I then created an exemption NAT to allow my laptop to communicate with the network 172.16.16.x.  Here is the config:

    access extensive list ip 172.16.16.0 inside_nat0_outbound allow 255.255.255.0 host 172.16.17.175

    Global (inside) 1 interface
    Global 1 interface (outside)
    global interface (guest) 1
    NAT (inside) 0-list of access inside_nat0_outbound
    NAT (inside) 1 0.0.0.0 0.0.0.0
    NAT (guest) 1 0.0.0.0 0.0.0.0

    It works fine, but I cannot activate the EZVPN remote that I have configured on the SAA.  Here is the error:

    Output from the command: 'vpnclient enable '.

    * Delete "nat (inside) 0 inside_nat0_outbound.

    CONFLICT of CONFIG: Configuration that would prevent success Cisco Easy VPN remote
    operation was detected and listed above. Please solve the
    above a configuration and re - activate.

    I'm looking for two things, to explain why it is and why it is not allowed and help to set up a work around so that the two can be activated.  Any help would be appreciated.

    Thank you

    Steve

    OK, logical now.

    NAT exemption is so out of the game according to the guidelines of my post above (can't configure easy VPN and NAT exemption remotely on the same ASA).

    Second option, I have not tested myself, so just my theory that you can test:

    no nat control

    Since you have not stated nat on your external interface, it should allow that access you.

    Or third option, never tested:

    permit access-list static-sheep ip 172.16.16.0 255.255.255.0 172.16.17.0 255.255.255.0

    public static 172.16.16.0 (inside, outside) access list static-sheep

    Unfortunately, there are limited once the ASA is configured as Easy VPN remote, as it is supposed to be used just to access the HQ site.

  • get the error ORA-30483 (window functions not allowed herevv)

    Hi all
    Oracle version: 11.2.0.2.0

    with Table_dm AS
    (select 1 month_no, "wk1" week, DM_AMT 120, 300 GRoss_Amt, Week_no 4, Gross_qty 12, 1000 dm_adj_total double
    UNion all
    Select 1 month_no, "wk2" week, DM_AMT 120, 300 GRoss_Amt, Week_no 4, Gross_qty 12, 1000 dm_adj_total double
    Union of all the
    Select 1 month_no, "wk3" week, DM_AMT 120, 300 GRoss_Amt, Week_no 4, Gross_qty 12, 1000 dm_adj_total double
    Union of all the
    Select 1 month_no, "wk4" week, DM_AMT 120, 300 GRoss_Amt, Week_no 4, Gross_qty 12, 1000 dm_adj_total double
    Union of all the
    Select 2 month_no, 'wk5"week, DM_AMT 200, 400 GRoss_Amt, Week_no 5, Gross_qty 20, 1000 dm_adj_total double
    UNion all
    Select month_no 2, "wk6" week, DM_AMT 200, 400 GRoss_Amt, Week_no 5, Gross_qty 20, 1000 dm_adj_total double
    Union of all the
    Select month_no 2, "wk7" week, DM_AMT 200, 400 GRoss_Amt, Week_no 5, Gross_qty 20, 1000 dm_adj_total double
    UNion all
    Select month_no 2, "wk8" week, DM_AMT 200, 400 GRoss_Amt, Week_no 5, Gross_qty 20, 1000 dm_adj_total double
    UNion all
    Select month_no 2, "wk9" week, DM_AMT 200, 400 GRoss_Amt, Week_no 5, Gross_qty 20, 1000 dm_adj_total double
    )
    Select month_NO, GROSS_AMT
    (select
    mONTH_NO
    sum (first_value (GROSS_AMT) more (PARTITION MONTH_NO)) Gross_amt
    of table_dm
    Month_no group

    )

    get the following error

    "ORA-30483: window functions are not allowed here."

    The value of Gross_Amt must be the total of the Group month_no gross_amt (the Gross_Amt would be the first value in each month_no

    the value of Gross_Amt must therefore 700 in this case.

    Please suggest.

    AB

    Thank you very much, SY, is really a useful solution<>

  • ORA-00934: function of group not allowed error when creating index

    ORA-00934: Group feature is not allowed here
    create index idx_emp on emp(max(install_time))

    Hello

    Daniel wrote:
    ORA-00934: Group feature is not allowed here

    create index idx_emp on emp(max(install_time))
    

    It's true. It is documented in the Manual of the SQL language

    Restrictions on Function-based Indexes 
    
    Function-based indexes are subject to the following restrictions:
    ...
    The column_expression cannot contain any aggregate functions.
    

    MAX is an aggregate function.

    What problem are you trying to solve? If you could create an index like this, how would you use it?
    Explain what you need to do, and someone will help you find a good way to do it.

  • Error "function not allowed for the license.

    Hi all

    I get error "Function not allowed for license" when I'm collecting details of a custom user interface card.
    The user interface card called a Business Service that calls a service program.
    I wrote a page for the service program service.
    This error indicates which license?

    I use the BCC 2.3.1 and Eclipse SDK 2.2.0.5.

    Check the Admin Menu-> Installation Options framework-> Modules available to see if any module is disabled.

    Then go to the Menu Admin-> Configuration-> Feature Type = Module of Configuration feature and delete an entry of a module where the power is off.

    Try again the user interface card

  • vSphere HA is inside in vain. Operation is not allowed in the current state.

    Hello

    I'm testing vSphere HA with two hosts ESXi in my lab. I have a VM on each ESXi host and when I try to open HA by closing the port connection from the switch to one of the hosts, the cluster of vSphere tries to failover of the VM on the host failed to another host, but he is not successful.

    The events under the Cluster gives this warning:

    vSphere HA switched in vain < VM - > < Home > cluster < cluster name>. vSphere will try again if the maximum number of attempts has been exceeded. Reason: The operation is not allowed in the current state.

    Screenshot of the error is attached.

    I tried to restart the service of server vCenter and that did not help. What could be wrong here?

    Thank you.

    Shivani

    Hello adel.

    Do not disable the HA data store. If you have a physical server just power the server by pulling the power plug or just it crash. If you have virtual server vESXi, and then directly 'Power Off' there instead of the stop.

  • Not able to compile Func/Proc/trigger

    Hi all

    I took an environment (Windows server Db Version 11.2.0.1.0) export and imported even on Exadata machine (Db version 11.2.0.3.0).

    During the import, all the tables were created successfully, but all the proc/functions/triggers/packages have been compiled with errors.

    Now when I tried to compile them explicitly one by one I get

    ORA-00942: table or view does not exist

    And the same code is to be compiled in the previous environment

    Although all tables are there in this scheme, and I'm able to query the tables of the same session explicitly.

    And all grants were given to the user including the dba role.

    Can you please help me to know what I could be missing in the new environment

    Kind regards

    Jagdeep Seven

    My guess is that the tables in question are owned by another user.  My guess is that your stored procedures are stored procedures of all DEFINER rights.  And I assume that the user who owns the stored procedures has access to tables via a role not via a direct subsidy.  If these assumptions are correct, you need to grant the owner of access procedures to the tables directly not through a role.

    Privileges granted through a role (and DBA is a role) does not exist in a DEFINER rights stored procedure.

    Justin

  • trigger error autnomous mutation! Why not allow select in the trigger body?

    case 1. a user updates the table and this user has not committed, even fire user select request, he would get an old result. but no error.

    case 2. We have table x, trigger appears on the table x as soon as the table is updated to trigger fires. inside the body that we select just for table 'x' it throws error error changing table
    can someone please explain why?

    my example as follows:
    case 1:
    CREATE TABLE MyTable
    (NUMBER of c1);

    INSERT INTO myTable VALUES (1);
    commit;
    INSERT INTO myTable VALUES (2);

    Select * from myTable;
    C1
    ------------
    1




    case 2:
    CREATE TABLE myMaxTable
    (maxValue NUMBER);

    CREATE TABLE MyTable
    (NUMBER of c1);

    INSERT INTO myMaxTable VALUES (NULL);
    COMMIT;

    CREATE OR REPLACE TRIGGER myTrigger
    AFTER ON INSERT myTable
    FOR EACH LINE
    BEGIN
    UPDATE myMaxTable
    SET maxValue = (SELECT MAX (c1) FROM MaTable);
    END;
    /
    INSERT INTO myTable VALUES (1);

    INSERT INTO myTable VALUES (1)
    *
    ERROR on line 1:
    ORA-04091: table HUNBUG. MYTABLE is changing, function of triggering/can not see
    ORA-06512: at "HUNBUG. MON_TRIGGER', line 2
    ORA-04088: error during execution of trigger ' HUNBUG. MYTRIGGER'

    Assume that you are doing something like this:
    You have three records in the table:

    INSERT INTO myTable VALUES (1);
    
    INSERT INTO myTable VALUES (2);
    
    INSERT INTO myTable VALUES (3);
    

    Then do you one insert call to do more than three:

    INSERT INTO myTable
    SELECT c1 + 100
    FROM myTable;
    

    This last call insert inserts 3 records in your table - 101, 102 and 103.

    When you have a trigger FOR EACH ROW, which will be called three times, but there is no way to predict in what order, and when the trigger will fire for example at c1 = 102, the table is the "mutation" - it is located in the heart of a change and you don't know if 101 or 103 or both is in the table. Oracle does not allow you to do a select on the table of this mutation.

    When you remove the FOR EACH ROW clause, the trigger only will be called once at the end of this call to insert, moment in which the table is no longer changing and so your code will be located safely c1 max.

  • Can not see all the stored procedures in the Entity Data Model Wizard

    I hope it is a simple oversight on my part I try to use the new beta version of odp.net with entity framework support. I can open the Entity Data Model Wizard, give him my information database, and I can choose various tables to use successfully. But in the list where I select the tables, views and stored procedures, the wizard does not see my stored procs or my point of view.

    Does anyone know why he would see the tables but not views or stored procedures? My procs can be found under "packages" If that makes a difference. I tried to create a fictional stored procedure at the level above the title of 'procedures', but it is unclear whether.

    Is it possible for me to debug this from here? The log files, I could watch that would help me?

    Thank you
    Jim

    I belive your Oracle database 10 g such as 9iR2 predates.
    ODP/EF Beta does not list the stored procedures or functions when connect you to a database Oracle 10 g before.

    Readme.txt:
    4. the procedures are not compatible with the DB 9.2.
    Thus, there is no stored procedure listed by the EDM Wizard for 9.2 DBs.

Maybe you are looking for