Return by using the function number

How can I return number using the function.

Here is my procedure but do not in the name of variable or setting up as a variable...

create or replace function Calculate_number)
Number 1 in number,
Number2 number)
Return number is
Start
declare
number of result;

Select number1 + number2 as a result of double;


Return (result);
end;

Hello

You have not need double a lot in PL/SQL.

CREATE OR REPLACE FUNCTION Calculate_number
(
     number1 IN NUMBER,
     number2 IN NUMBER
)
RETURN NUMBER
DETERMINISTIC
IS
       result number;
BEGIN
     result := number1 + number2;

     RETURN Result;
END      Calculate_number;

Strored procedures, local variables are declared between statements IS and BEGIN. DECLARE in a stored procedure starts a nested block to BEGIN, with its own local variables, which is rarely necessary. (Nested BEGIN blocks are not so rare, but they almost never have local variables need a nested block. Most people here all variables of the function complete together before the first START.)

If the function always returns the same value when it is called with the same arguments, then Deniz it as DETERMINISTIC; It might make it faster to use.

There are many good reasons to use a variable as results, but if you don't happen to have one, then you can do this:

CREATE OR REPLACE FUNCTION Calculate_number
(
     number1 IN NUMBER,
     number2 IN NUMBER
)
RETURN NUMBER
DETERMINISTIC
IS
BEGIN
     RETURN  number1 + number2;
END      Calculate_number;

Published by: Frank Kulash, October 22, 2010 12:37
Fault corrected typo (thanks, HM); Added after the remarks.

Published by: Frank Kulash, October 22, 2010 13:28

Tags: Database

Similar Questions

  • Using the function PLSQL return Record Type Index of Tables in ADF

    I have a PLSQL function, a return type. My ultimate goal is to take this binary integer index Table and print it on the screen...

    CREATE OR REPLACE PACKAGE my_pkg IS
     
    TYPE t_col IS RECORD(
     
    i NUMBER,
     
    n VARCHAR2(30));
     
    TYPE t_nested_table IS TABLE OF t_col;
     
      FUNCTION return_table RETURN t_nested_table ;
    END my_pkg;


    OPTION 1:

    1) has anyone got best practices to accept plsql RECORDS returned by a function?

    Here is an example.

    http://adfpractice-Fedor.blogspot.SG/2013/01/working-with-PLSQL-procedures-in-ADF-BC.html

    But it will be a lot of work... first of all accept the results in a loop... then store in a temporary storage can be a few VO or global temporary table and then display them on the page


    OPTION 2:

    Using the functions PIPLELINED and use in the select statement.  While I can use this select statement in the SQL query to create VO... and drag and drop the VO...

    CREATE OR REPLACE PACKAGE my_pkg IS
     
    TYPE t_col IS RECORD(
     
    i NUMBER,
     
    n VARCHAR2(30));
     
    TYPE t_nested_table IS TABLE OF t_col;
     
      FUNCTION return_table RETURN t_nested_table PIPELINED;
    END my_pkg;


    select * from table(my_pkg.return_table);


    Wow... I'm so smart! .. really possible?  who is the best/possible/recommended option?

    I'm sure that will be the question most read by many who wants to use PLSQL instead of JAVA to the treatment and CHOSEN to use only to display the output of the PLSQL functions or procedures.


    Thank you

    Rahul


    Dario

    Do you mean the scope of the defined Type pkg will be finished?

    I created guy outside the pkg as 'Create Type' if it works in this case?

    Yes, level objects schema (created with "create or replace type...") can be used in java and this can work.

    I think that then the scope of this TYPE will remain until the user session passes.

    Object definitions is not worn, but have their bodies.

    So, if you instantiate the data level object type schema in a plsql function, scope of this object is this function.

    Of course, if you instantiate the object as a variable package, then life of this object is equal to the lifetime of the package (which usually equals life of session db).

    Dario

  • Create the view and by using the function that returns a type oracle

    Following is possible?

    A function returns an ORACLE object Type, and I want to use this feature, in my opinion, it is possible to access each field of the type once the function is executed and make a column in the view?
    create or replace TYPE SOME_INFO AS OBJECT
    ( 
      CHARGE FLOAT,
      SOME_DATE DATE,
      SOME_VAL VARCHAR(50)
    );
    
    CREATE OR REPLACE
      FUNCTION CALCULATE_INFO
        (
          p_chargeId NUMBER)
        RETURN SOME_INFO 
      AS 
      v_some_info SOME_INFO := new SOME_INFO(0, null, null);
    BEGIN
     
    -- function body populates the v_some_info
    return v_some_info;
     
    END calculate_info;
    Now, I want to use the function according to me - if the underlying query of the view follows-
     select c.*, calculate_info(c.charge_id) as someInfo from some_charge;
    How to recover someInfo.CHARGE, someInfo.some_date, someInfo.some_val? I can put them as columns in the view?

    If you use only functions that return a single value in a view?

    Thank you
    Mustapha

    Published by: Tina Giri on April 16, 2009 05:47

    How to recover someInfo.CHARGE, someInfo.some_date, someInfo.some_val?

    SQL>  create or replace type some_info
    as
       object (charge float, some_date date, some_val varchar (50));
    /
    Type created.
    
    SQL>  create or replace function calculate_info (p_chargeid number)
       return some_info
    as
       v_some_info   some_info := new some_info (0, null, null);
    begin
       -- function body populates the v_some_info
       return v_some_info;
    end calculate_info;
    /
    Function created.
    
    SQL>  select your_view.someinfo.charge,
           your_view.someinfo.some_date,
           your_view.someinfo.some_val
      from (select c.*, calculate_info (c.empno) as someinfo
              from emp c) your_view where rownum <= 3
    
    SOMEINFO.CHARGE SOMEINFO SOMEINFO.SOME_VAL
    --------------- -------- --------------------------------------------------
                  0
                  0
                  0                                                            
    
    3 rows selected.
    
  • Is highest Null or more low value? using the fewest number of function...

    So Null is one of the if not the highest value in a list of values.

    Whenever I order a column, null has always been highest.

    However, when I use the function less

    Select * from bills by terms_of_discount desc;

    Select LESS ('2 ', '5', '12', ' 3', null) double;

    Select the LEAST ('apples', 'apps', 'applas', null) double;

    In both cases the null value is the lowest

    so I wonder why this is.

    As mentioned in oradocs:

    DESCRIPTION

    The Oracle/PLSQL LESS function returns the smallest value in a list of expressions.

    It's the greatest or least. As soon as you try to use the NULL value in a comparison, the answer is unknown.

    So, if you have NOTHING in there, the answer will be NULL.

    It goes the same for GREATEST().

    Global functions (SUM, MIN, MAX, etc) ignore NULL values.

    In ORDER BY, you can specify NULL FIRST or NULLS LAST.

  • When you modify a form in the DC or Pro Player I can enter text etc., save, close, and return later to change it. However, once I use the function "Fill &amp; Sign" and save the document, it locks the file and all other fields are not editable. Is there a

    Hi guys,.

    When you type information in a form in the DC or Pro Player I can enter text with fields of text etc and then save, close and return later to change the form. However once I use the function "Fill & Sign" to sign the document, and then save, it locks the file and all other fields become editable. Is there a way around this to remove this feature where it becomes locked and instead allows me to change the form after a signature is applied and saved. All the security properties of the form are on 'admitted', there is no restriction. Even though the document is locked all the properties remain still as 'authorized '.

    The signing is FINAL.  You cannot sign a PDF paper advance. Complete and save, do not sign.

  • How to use the function @RETURN for poster messages Essbase in 11.1.2.1

    Hello

    I found the business support Essbase Hyperion Planning 11.1.2.1 @RETURN rule novelty.

    If I create a simple BR for planning app like below:
    "@RETURN ("test return message,"WARNING);
    Validation returns error and BR can not be deployed.

    One is how to use the function @RETURN br?

    Thank you!

    He probably should be in a calco for example block

    "Profit".
    (
    ....
    )

    It is more likely to be used with an IF ELSE command, you do not want to define the condition for the calculation, roughly what the feature is designed for output.

    See you soon

    John
    http://John-Goodwin.blogspot.com/

  • need help on image blob retriving of table... I need to use the function

    I have a single display field and I tried to retrieve a value using the function... The idea of using the BLOB comes from the following example...
    http://dgielis.blogspot.in/2008/07/show-blob-of-other-table-in-apex-form.html

    I created the following function... has only function display.
    "return ' < img src =" "|" APEX_UTIL. GET_BLOB_FILE_SRC('P375_PICTURE',1204,,'inline') | '" />';

    but the output is undesirable character
    The output is the following
    < img src = "" apex_util.get_blob_file? a = 231 & s = 16387884076007 & p = 375 & d = 26249204291254605 & i = 26247831247254566 & p_pk1 = 1204 & p_pk2 = & p_ck = C226897F204BFA329F601AF2ED72ECDA & p_content_disposition = inline "/ >"

    Using apex 4.2 db 11g release 2 xe
    1204 here are a few magazine_id
    Here's my blob table structure
    xxx_picture
    xxx_no number (10),
    BLOB of photo
    picture_filename
    picture_mimetype
    image_last_update
    I am able to recover the data via interactivereport but I will lke to recover their data that show only the BLOB field

    Can someone please guide. . I could hurt
    Thank you

    Published by: zycoz100 on April 28, 2013 01:05

    zycoz100 wrote:
    I have a single display field and I tried to retrieve a value using the function... The idea of using the BLOB comes from the following example...
    http://dgielis.blogspot.in/2008/07/show-blob-of-other-table-in-apex-form.html

    I created the following function... has only function display.
    return '';

    but the output is undesirable character
    The output is the following

    To get a displayed item to render in HTML, in the definition section Security value escape special characters notitem.

    For a column of the report, ensure that the column attribute text to display as report is report Standard column rather than the default display text (escape special characters).

    However in the APEX 4.x, using an element in the Image display and support declarative BLOB is preferable to these manual methods. Images can be formatted using the HTML attributes of the element form of property, or via CSS element.

  • Using the function to retrieve several data

    using the function recover data of the hre_date and name of entry where are employee_id = 100. kindly give a query in PLSQL

    Padma... wrote:
    Hello

    create or replace function f1 (a number, b out varchar2) return date
    is
    c the date;
    Start
    Select last_name, hire_date b, c of the employees where employee_id = a;
    return c;
    end;
    /
    declare
    name varchar2 (30);
    Start
    dbms_output.put_line (f1(100, name));
    dbms_output.put_line (Name);
    end;

    Thank you
    Padma...

    Agree with Marwim, using OUT parameters is very bad practice.

    Something would be more appropriate...

    SQL> create or replace function get_emp(empno in number) return sys_refcursor is
      2    rc sys_refcursor;
      3  begin
      4    open rc for 'select hiredate, ename from emp where empno = :1' using empno;
      5    return rc;
      6  end;
      7  /
    
    Function created.
    
    SQL> var rc refcursor;
    SQL> exec :rc := get_emp(7788);
    
    PL/SQL procedure successfully completed.
    
    SQL> print rc
    
    HIREDATE             ENAME
    -------------------- ----------
    19-APR-1987 00:00:00 SCOTT
    
    SQL>
    

    If the customer requires a Ref cursor returned with data, otherwise a registration type / adapted collection could be returned and the integrated data to the that, although in general the collection of data in memory and the passage on the procedures is not the most ideal because it takes up resources such as memory of the PGA.
    Without special requirements, it is impossible to give a precise answer.

  • I want the single update query without using the function.

    I want to update sells_table selling_code field with product_code date product table max.
    In the product table, there are several product_code date wise.

    I did with below charly with the use of the service, but we can do in the query what a single update
    without using the function.

    UPDATE sells_table
    SET selling_code = MAXDATEPRODUCT (ctd_vpk_product_code)
    WHERE NVL(update_product_flag,0) = 0;

    (P_product IN VARCHAR2) RETURN of HVL.maxdateproduct NUMBER FUNCTION to CREATE or REPLACE
    IS
    max_date_product VARCHAR2 (100);
    BEGIN
    BEGIN
    SELECT NVL (TRIM (product_code), 0)
    IN max_date_product
    FROM (SELECT product_code, xref_end_dt)
    PRODUCT
    WHERE TO_NUMBER (p_product) = pr.item_id
    ORDER BY xref_end_dt DESC)
    WHERE ROWNUM = 1; -He'll be back a single line - max date product code
    EXCEPTION
    WHILE OTHERS
    THEN
    RETURN 0;
    END;

    RETURN max_date_product;

    END maxdateproduct;

    Thanks in advance.

    Hello

    Something like that.

    update setlls_table st
            set selling_code =(select nvl(trim(product_code)) from
                                  (select product_code
                                          , rank() over (partition by item_id order by xref_end_dt DESC) rn
                                       from product
                                   ) pr
                                   where rn =1
                                         and pr.item_id = st.ctd_vpk_product_code
                               ) where NVL(update_product_flag,0) = 0 ;
    

    That such is not tested due to lack of sampling input.

    Concerning
    Anurag Tibrewal.

  • Color image is not displayed when we call using the function DAL (LOGO)

    Hi all

    To change a picture of the legacy of the new Image in our MRL, the legacy Image is used by a lot of Faps (sections).

    (1) if we create the new article with new Images, the process becomes complex, as we need to check all the triggers and forms associated with it.so, we plan to create a field (with the same position as picture) DAL with functions of LOGO use

    EX:

    If (#process = 1)

    LOGO ("Idea", Fieldx (), Fieldy ())

    on the other

    LOGO ("LegacyImage", Fieldx (), Fieldy ())

    End

    Return("")


    Problem: The new Image is colored but when printed (called using "DAL") that is the impression that 'Black and White')

    We tried to use 'Refresh() '.


    Kindly help me with solutions,


    Thanks in advance

    Try to use the function ChangeLogo DAL instead.

    Change a logo on a section that has the set of attributes "print in color.

    This preserve the parameter "Print in color" and the logo print in color.

    See Re: how to get the graph to print in color when it is added using script

  • I want to rename and move files from a shoot 5 d. I would like to use the functionality of the increment to count, but since I have to get out of each file to the following file, it starts again at 1. What is the best way to do it?

    I want to rename and move files from a shoot 5 d on a new drive. I would like to use the functionality of the increment to count, but since I have to get out of each file to the following file, it starts again at 1. What is the best way to do it?

    HI -.

    As a prelude to 2014.0, we have added a feature allowing you to choose what number to start the increment of.  Look in the section ingest Rename dialog and change your preset. When you click the button, you should see the option "Custom Auto Increment". This will allow you to choose what number to start on.  We've also added a few newspapers to try to remember where let prelude last successfully interfere the operation by using this option. So, in theory, to remember the number for you. But if it isn't (maybe you want multiple kickoff ingested at the same time) you can always manually set the number to start with.

    Check that out and let me know how it works for you.

    Kind regards

    Michael

  • I have an iMac 27' 2012 with macOS Sierra and Apple Watch with watch OS 3, I can use the function "Log?" in Apple Watch

    I have an iMac 27' 2012 with macOS Sierra and Apple Watch with watch OS 3, I can use the function "Log?" in Apple Watch

    Hi John 2078 Tito.

    I understand that you have updated your iMac and Apple Watch and now you're curious about unlock your iMac using your Apple Watch. I know that it is a nice feature to be able to quickly and safely unlock your computer, so I'm happy to help you.

    This feature is available on 2013 iMacs and later versions, which means that your iMac won't be compatible. You can see more info on this feature here:
    Unlock your Mac with Apple Watch - Apple Watch user's Guide

    Thank you for using communities Support from Apple. See you soon!

  • I lost my ipad I need to add the device to icloud by using the serial number. Can I do this?

    I lost my ipad I need to add the device to icloud by using the serial number. Can I do this?

    N ° you can not add it without physical access to the device.

  • I have been using the functionality of Firefox in which I could have multiple sets of tabs open, but only see the game I was working with. I have updated and now the functionality is Gone

    I have been using the functionality of Firefox in which I could have multiple sets of tabs open, but only see the game I was working with. I have updated and now the feature disappeared. I had a small icon on the top right of my toolbar. I used it all the time to keep windows separated for financial, plans to travel items, news, etc.. Has it been removed from Firefox?

    Hello

    The feature of tab groups is always present. You can try with the button right of the + after the last tab and Customize. If the icon is hidden behind the other, or if it is available inside the mini window customize, you can put it back. If the problem persists, you can also try of reset toolbars and controls: and start to make changes and restart in Safe Mode screen.

  • How and where can I find my Macbook Pro using the model number

    How and where can I find my Macbook Pro "using the MODEL number" NOT the serial NUMBER please...

    Hello world:

    I would like to know more about my MacbookPro using model # is if there is a website or a program that I can type my model # so she'll tell me more on my computer...?

    http://www.EveryMac.com

Maybe you are looking for