Function with several variables

I tried to write a function to know the date difference.

CREATE OR REPLACE FUNCTION DATEDIFFER
(P_WHAT VARCHAR2,
P_D1 DAY,
P_D2 DAY,
)
RETURN AS NUMBER
NUMBER OF I_RESULT;
BEGIN
SELECT (P_D2 - P_D1) *.
DECODE
(
UPPER (P_WHAT),
"SS", 24 * 60 60,
'MI', 24 * 60.
"HH", 24.
NULL VALUE
)
IN
I_RESULT;
END;

But this function fails with the compile error. Not sure if something wrong.

>
Don't know if something wrong
>
Are you serious? Why it would fail if there wasn't something wrong?

CREATE OR REPLACE FUNCTION DATEDIFFER
( P_WHAT VARCHAR2,
P_D1 DATE ,
P_D2 DATE  -- #1 - you had a comma here after the last parameter
)
RETURN NUMBER AS
I_RESULT NUMBER;
BEGIN
SELECT (P_D2 - P_D1) *
DECODE
(
UPPER(P_WHAT), 'SS',24*60*60, 'MI',24*60, 'HH',24, NULL )
INTO
-- I_RESULT; -- #2 - you have to select from a table -ERROR line 19, col 9, ending_line 19, ending_col 9, Found ';', Expecting: FROM   -or-   ,   -or-   .   -or-   (   -or-   @
I_RESULT
 FROM DUAL;
END;

Tags: Database

Similar Questions

  • Problems of execution of a SQL function with a variable in the WHERE clause

    Hello world!

    I have programmed a function that returns a boolean value based on the result of the SQL. It's the function:

    FUNCTION existe_secuencial (seq_name VARCHAR2) RETURN AS BOOLEAN

    cursor c2 is SELECT FROM all_sequences WHERE upper (sequence_name) = sequence_name' | seq_name | ' ;

    BEGIN

    OPEN c2;

    DBMS_OUTPUT. Put_line (nombre_seq);

    Get c2 INTO kk;

    If c2% NOTFOUND = True THEN

    RETURNS false;

    on the other

    RETURNS true;

    end if;

    END existe_secuencial;

    And I give the floor to the function of a procedure in this way:

    IF existe_secuencial ("SEQ_ARQUETA") = True THEN

    DBMS_OUTPUT. Put_line ('exists');

    ON THE OTHER

    DBMS_OUTPUT. Put_line ("' NOT exists");

    END IF;

    The probrem that this SQL is forced to return results because this sequence exists in the comic book, but is not, return me the FALSE value. What makes me mad is that if I change the second line of the function in this way:

    > > cursor c2 is SELECT FROM all_sequences WHERE upper (sequence_name) sequence_name ="SEQ_ARQUETA";

    It works find and return of sequence existing (real)

    Can someone help me please, I'm quite desperate to find what is the problem with that because I do not understand why if I built the slider with a variable returns no results so that if I do write it works...

    Thanks in advance!

    Itziar

    Frame you your variable in quotes, which makes the string literal ' |. ' seq_name | "rather than the content of the variable.

    I think that something like this would be an improvement.

    function existe_secuencial (seq_name VARCHAR2) return a Boolean value as

    number of exist_check: = 0;

    Start

    Start

    Select 1

    in exist_check

    of all_sequences

    where upper (sequence_name) = upper (seq_name);

    exception

    When no_data_found then

    null;

    end;

    return (exist_check = 1);

    end existe_secuencial;

  • function with a variable number of cubic curves

    Hello

    I have a set of data : a set representing the independent variable and a set representing the dependent variable. I need to find the minimum number of cubic curves (find their coefficients) that reduce the average quadratic error less than a given tolerance. If the tolerance is higher than 17 particular segments, so I need to raise an error.

    You have an idea what function blocks, I need to?

    I could use general polynomial Fit VI with order 3 and its default method to check the residue. If the residue is greater than the given tolerance, so I could try to use two cubic curves and test them on different starting and ending points until the residue is less than the given tolerance. If tolerance is not guaranteed, I add another curve and I test again the Assembly as shown above. By iteration until the residue is less than the given tolerance, or until I would need to add 18th cubic curve.

    If there was something ready, I would be grateful.

    Thank you.

    Fabiobonelli wrote:

    Please, you can test your VI adding another point to four present?

    X =-6453

    Y =-266

    Check the residue.

    Thank you.

    Did you even read my response? You have a serious air conditioning problem because the data is on a narrow Beach far from zero. By example-6500 ^ 3 is smaller that - 2E11, i.e. a value that many (many!) is orders of magnitude different from that of the constant term (1). The linear algebra problem that results is very ill, conditioned and just blindly Ford over the accelerator pedal are bad advice here.

    This isn't a problem with the implementation of LabVIEW, but a fundamental vice that you encouter also (or worse) If you would do your own math. No way around it. (See also)

    My recommendation is to delete the X offset and add it later again. Now things work correctly. (Note that a second order polynomial fitting still works without twist it).

    Try the and see for yourself.

  • How to generate URLS with several variables of input fields?

    I create an ad with four text fields labels fname, lname, city and province, and I wanted to know how to generate URLS based on the information entered in the fields. The text of the default fields to display "Name," "Last Name", "City" and "State", respectively, but if a user does not enter information in these fields, I want the URL to behave as if those who were empty, if that makes sense. Text fields are in a clip called 'input_text' and the button is titled 'send '. If any of you can provide insight, I would greatly appreciate. Thank you.

    1 use the instructions to see if if the properties your textfields text meets your requirements for the creation of this url.

    2. you can use the properties and methods string flash to create your url.

    p.s. the + sign can be used to concatenate strings.

  • Need help with choice variables remain in the new session

    I have a set of approx. Flash to the top with several variables. Y at - it a simple action script that will allow the user to maintain their choice after the closure of the .swf and revive it?
    Thanks in advance for your help.

    How do check you if these components have been checked or ticked. in fact, I probably don't want to know that.

    you really recommended to use a listener to detect when your components have changed and then you can use the modified method to define your variables and update your sharedobject.

  • Functions defined by the user with several parameters

    I set features three following user using "Define."

    UF1 takes a single patameter;

    UF2 takes two parameters;

    and UFX takes two parameters - with the second is 'X' in the definition.

    Œuvres F1.  F2 is the EVAL of F1 version and it works too.  User functions only seem to work fine.

    F3, a function of two user settings, produces a graph of NaN.

    F4 is the EVAL of F3 version.  Note that 'B 'is not replaced by 1'.  Also produces a NaN chart.

    F5 produces a graph of NaN.

    F6 is EVAL of F5.  The 'X' is not replaced (even with the ' B' above), and even if it looks like 'X * X', it also produces a graph of NaN.

    Is it possible to get defined by the user, with several parameters, features work by tracing the curve?

    Hi!, Fortin:

    If you download and install the ultimate Firmware with the version of the software: 2015 6 17 (8151), with the number of Version: 1.1.2 - 11, you can trace your examples of definition of the function, with curves and values, without NaN.

  • DATACOPY function problem using several variables quick

    Hello

    I have problem when I use more variables and then a quick calculation with DATACOPY function. When I put a prompt variable in function DATACOPY it works but when I add one or more it gives me error Essbasse (I can see it in the Essbase Administration journal not in the syntax checking process):

    Not valid [Calc Script syntax

    DATACOPY Q1020-> Dec-> 'FY14'-]

    [Fri Jul 11 15:04:25 2014] Local/TS_PLAN/Prihodi/admin@Native Directory/1004/Error (1200421)

    Error occurred at or after the line [8]

    -Essbase put FY14 because it is rapidly Variable in this error above.

    I try datacopy function with this:

    DATACOPY Q1020-> Dec-> "FY14 '... It works

    DATACOPY Q1200-> Dec-> {YearPrompt}... It works

    DATACOPY Q1200-> Dec-> {YearPrompt}-> {ScenarioPrompt} it doesn't it break on variable ScenarioPrompt.

    Thank you

    Finally, I solved my problem. That was the problem Essbasse how to understand the spaces between the dimensions. I didn't not use quotes for members and I put space between the arrows. It gave me an error I think because he did not understand space as the space. Now, when I use quotes and remove the space between the arrows cross dimensions it works.

  • PL/SQL-function with variable number of parameters

    Hello

    I want to write an INLIKE function that combines the functions of the po and AS operator.
    I want to call it that:

    SELECT 1 in the table where INLIKE (column, Motif1, pattern2,...) with a variable count of bosses.

    Is there a possibility the java selection button (String... stringArray) to declare or to make, I have to define a function with multiple parameters and default values?

    With greetings

    Florian

    You don't need to write a function no., you can use regular expressions REGEXP_LIKE...

    for example to find all the rows that have % ED % or % LY in them...

    SQL> ed
    Wrote file afiedt.buf
    
      1  with t as (select 'FRED IS SCARED' as txt from dual union all
      2             select 'EDWARD IS HAPPY' from dual union all
      3             select 'BOB AND TIM ARE ASLEEP' from dual union all
      4             select 'JIM AND SALLY DO NOT CARE' from dual)
      5  --
      6  -- END OF TEST DATA
      7  --
      8  select *
      9  from t
     10* where regexp_like(txt, '(ED|LY)')
    SQL> /
    
    TXT
    -------------------------
    FRED IS SCARED
    EDWARD IS HAPPY
    JIM AND SALLY DO NOT CARE
    
  • Simulation & Control with local variables

    Why should I use a local variable in a loop of simulation, but not in a Subvi simulation?

    Local variables will only work in a Subvi are those that relate to controls or indicators located in the Sub - VI.  If you need to pass data between different from the Subvi, so you have several choices.

    1. common variables, as you said.

    2. global variables, as you said.

    3. pass the data in or out through the pane of the connector of the Subvi.

    4. functional Motors Global Variables/Action.

    5 lines of

    6. the references to the controls in the VI main so that they be used with nodes of property in the Sub - VI

  • Closure of a state machine in queue event with several parallel loops

    I am trying to find the best way to stop a program that consists of an architecture of State machine in line waiting for event with several parallel loops. Can anyone recommend the best way to achieve this in my attached VI? (To browse the forum, this seems to be a frequently asked question, but I have not found a solution that works for me.)

    I look forward to any comments on my as well code, if someone is willing to offer it.

    My program needs:

    If the user press the 'Stop' button, the program should prompt the user with "are you sure you want to stop the program?" and then return to a State of rest or move forward to stop the program. In addition if there is an error, the program should prompt the user to ' clear the error and continue, or stop the program. Then back to the idle state or move forward to stop the program.

    Architectural details:

    The program consists of 3 parallel loops: (1) a loop of event management that places different States of a queue of the State, (2) a State Machine that enters the State that is removed from the queue of the State and (3) a loop error/Shutdown, which deals with errors in the error queue management.

    During normal shutdown, where running handling loop in the case of event 'Program.Shutdown' and 'Shutdown' and the 'Idle' States are added to the queue of the State. In the state machine, the State of 'Stop' is invoked. Special "5000" error code is added to the queue of the error. In the loop of error handling and stopping, "5000" error triggered a prompt that asks the user if they want to stop the program. If the user chooses not to stop, a notifier StopNotif is sent to the State of 'Stop' and 'Program.Shutdown' event case with notification 'Go '. If the user decides to stop, the Notifier sends the notification "Stop". Loop and event management State Machine ends when they receive the notification "Stop".

    In case of error, the program behaves in the same way: If the user chooses to clear the error and continue, the program returns to the status "pending".

    HOWEVER - if the user chooses to stop the program, the program crashes. The author of the notification that is sent to stop the loop of events and State Machine management cannot be read because event Program.Shutdown and the stop State (which contain the function "Waiting to notify") are not active.

    I was able to activate the stop State by Queuing in the loop of error/Shutdown management. But I don't know how to activate the "Program.Shutdown" event by program and thus access the function "Waiting to notify" inside.

    I tried to put the function "Waiting to notify" outside the structure of the event, so the event-handling loop never ends. Placing timeouts on the "wait for declaring" and the structure of the event makes the programme of work, but I want to avoid using timeouts because I don't want to turn my event program into a program of polling stations. I would also avoid using variables or nodes property to stop loops, because that requires the creation of a control/indicator for something that the user does not need to interact with.

    Thank you!

    First of all, close the notifier outside loops with your queues.  Second, you must use a user event to send the message to the event structure loop so that it stop in the case of the stop on an error.

  • APEX 4.2 translate data 'function and Global Variable declaration '.

    Hello everyone,

    I use APEX 4.2.1.00.08 and I wonder if there is a way to translate "Function and Global Variable declaration" textarea. Any other script text box is available for translation, but not this one.
    I know what the code is loaded on the header, but may contain important alert messages of global functions.

    Thanks in advance.

    Hi Grandmaster,

    "Function and global variables declaration" contains the JavaScript code, that is why it is not wise to include in the standard translation process.

    In my opinion, you have several options to access your translated messages:

    -) Use Application-> Substitutions or
    -) Store your message in the form of component shared-> SMS and and assign it to an application with the APEX_LANG element. Api MESSAGE (http://docs.oracle.com/cd/E37097_01/doc/doc.42/e35127/apex_lang.htm#CHDBCEAB)

    In 'Function and Global Variable declaration' use substitution syntax to replace the value. For example:

    var myDeleteMessage = "&G_MY_DELETE_MESSAGE.";
    ...
    alert(myDeleteMessage);
    

    where G_MY_DELETE_MESSAGE would be a part of the application or the request for Substitution.

    Concerning
    Patrick
    -----------
    Member of the APEX development team
    My Blog: http://www.inside-oracle-apex.com
    APEX Plug-Ins: http://apex.oracle.com/plugins
    Twitter: http://www.twitter.com/patrickwolf

  • Slide several boxes and align itself with several locations and reveal the button

    Hi I am developing a game where the user chooses from a range of boxes to the left of the screen and can drag the 3 of them separately from 3 boxes to right ther. each box can be moved anywhere, and the order is not important. Once the 3 boxes are all full, I want a new button to appear. I finished a tutorial and I have a box works perfectly, but no matter what I try, I can't work with several boxes and locations. Here is a list of the instance names of film clips more my actionscript. I have attached a link to the flash file. Any help would be really appreciated. See you soon

    LINK

    http://www.sainters.NET/flash_preview/flash_test/Flash test_v6.fla.zip

    INSTANCE NAMES

    1 box = 'circle_mc.

    Box 2 = "circle_mc2."

    the two grey boxes are called = "targetCircle."

    ACTIONSCRIPT

    function dragSetup (clip, targ) {}
    clip.onPress = function() {}
    startDrag (this);
    this.beingDragged = true;
    };

    clip.onRelease = clip.onReleaseOutside = function () {}
    stopDrag();
    this.beingDragged = false;
    If (eval (this._droptarget) == targ) {}
    this.onTarget = true;
    _root. Targ.gotoAndStop (2);
    } else {}
    this.onTarget = false;
    _root. Targ.gotoAndStop (1);
    }
    };
    the following variables can store the start position of clips
    clip.myHomeX = clip._x;
    clip.myHomeY = clip._y;
    the variables below are going to store the position of end of clips
    clip.myFinalX = targ._x;
    clip.myFinalY = targ._y;
    clip.onEnterFrame = function() {}
    all these actions basically just to say "If the mouse is in place (in other words - the clip is not moved).
    then replace the MC to its original start (with a smooth movement) point ".
    If (! this.beingDragged & &! this.onTarget) {}
    This ._x-= (this._x-this.myHomeX)/5;
    This ._y-= (this._y-this.myHomeY)/5;
    If the circle is moved on any part of the target, it slides toward the center of the target
    } else if (! this.beingDragged & & this.onTarget) {}
    This ._x-= (this._x-this.myFinalX)/5;
    This ._y-= (this._y-this.myFinalY)/5;
    }
    };
    }

    dragSetup (circle_mc, targetCircle);

    You can probably do all the things you want to do.  I will make them for you well.  Trying to figure out how what I've provided works and then try to reason things for the changes you want to perform.

  • Several Variables in a text box or text field


    Is there a way to set different variables in a text area so that spacing between the line will be compatible?


    Or do I need to break the text box in separate text fields?

    (I searched the forum but have not found an answer.)

    It's really very simple. I wonder if there is a way to have more than one variable in a textframe?

    What do you mean by "variable"? Has Illustrator to an entire function defined in the user interface, called Variables. There are a range of Variables. If that's what you're talking about, then no, you can't bind multiple variables in a single text object. The so-called Variables data-driven are related to the object level.

    If you're talking about the generic term of 'variable' in the sense of a script language, then Yes, of course you can replace text different ranges within a single textFrame with the values of several variables - as long as the values of the variables in question are text. Or, you can use the text of text ranges in one or more frames of related as the values of several variables.

    Or should I abandon this script and write my own?

    Yet once, nothing more than a description very vague and General what exactly you're trying to do. So, Yes, given that the purpose of this script is to simply concatenate the contents of several frames of text bound in one alone, and it is quite complex, my guess would be that you need to write your own.

    Basically, if I have a list of addresses and hours of operation in a dataset. Currently, they are divided into separate, linked text frames.

    Again, you use a term (dataset) which implies that you do refers to the function of Variables in Illustrator. If you speak only attach the text of several frames of separate linked text in Illustrator into one, you can do this in the user interface without any manuscript at all: just copy multiple text objects, download the text and create a new text object and paste tool.

    If you need space, paragraph returns, or some other delimiter inserted at the beginning or end of objects separated prior to joining them through the normal in the user interface, you can take a look at the description of the scripts here named JET_ConcatenateTextAtEnd and JET_ConcatenateTextAtStart.

    JET

  • Using ChnCalculate with a variable

    The channel of LIN/LIN_Error has 3000 values inside. I want to add a correction value to each of the 3000 values inside.

    If I use a constant, it works well. For example:

    Call ChnCalculate ("Ch(""LIN/LIN_Error"") = (2 + Ch (" "LIN/LIN_Error" "" "))") adds 2 to each value.

    However if I try with a variable it does not work.

    Dim Corr

    GlobalDim "Corr".

    Corr = 2
    Call ChnCalculate ("Ch(""LIN/LIN_Error"") = (Corr + Ch (" "LIN/LIN_Error" "" "))")

    Hi Frank,.

    The problem is your first line.  By running 'Dim Corr' in the VBScript code, you force this variable name to refer to the variable in VBScript and not the variable global tiara - light color in the SCRIPT Panel does not reflect what is confusing.  If you remove the statement Dim Corr, and then the VBScript code will correctly reference the global variable.  Another way to put it is that your VBScript never affects the global variable to Corr 2.  The command correctly done ChnCalculate() refers to the global variable of Corr, but it is always set to 0.

    However, for this task, I'd recommend the ChnLinScale() function, which is simpler, will run faster, accepts regular VBScript variables and ignore so all this imbroglio.

    Dim Corr
    Corr = 20
    Call ChnLinScale ("LIN/LIN_Error", "LIN/LIN_Error", 1, Corr)

    Brad Turpin

    Tiara Product Support Engineer

    National Instruments

  • Digital control system, using limits of entry of data with global variables

    Hello!

    I have a Subvi with several digital control sliders. These control framerate, the pixel clock and exposure of a camera and their change in max/min/increment whenever one of them is changed - they are interdependent and get their information from the camera continuously during execution.

    I'm trying to remote control this VI, but during the passage of a value using global variables, it doesn't "stick".

    Example:

    The value for exposure is 237,48 Ms. different values are constrained to the nearest value. So if I pick 240,00 ms at the Subvi, he should know that this is not a valid value and change to Mrs. 237,48.

    But it is not do and I don't know why. When I enter the values manually, it works fine.

    Any suggestions?

    The limits on the controls that apply when their control from the front and is not passing values via the connector pane.

    You should use something like "line and force" within the VI to validate the values are within the range (maybe constrain data or return an error).

Maybe you are looking for

  • save you tube file

    Save option not to come after a long press on the video

  • Compaq: browsers

    No panic here, but I would be grateful for some advice if anyone has time to help. First of all, I was convinced, by Microsoft, for Windows 8 to 10 Windows.   If it's an improvement is a matter of opinion.   Windows 10 has made some of my existing st

  • Performance system for W530 scores?

    I would like to know what other system performance scores are (performance/system/control panel) on their W530s... specifically configured with : Intel Core i7-3720QM processor (6 MB Cache) NVIDIA Quadro K1000M graphics with 2 GB of DDR memory 8 GB D

  • Synchronize blackBerry Smartphones does not not in Office Manager

    I have Setup Automatic Synchronize so that it starts when I open the Desktop Manager.  It was working fine yesterday.  But today, when I opened the Desktop Manager (my camera was already connected via USB), he was looking for software upgrades (as us

  • Docs of blackBerry Smartphones to go icon

    I think having lost or deleted by Docs icon go.  Docs to Go appear on my list of applications being installed, but I can't find it on my homescreen.  Any ideas for what to do?  Thank you.