Tuesday 5 June 2018

Pragma UDF (User Defined Function)




CREATE OR REPLACE FUNCTION fn1 (
    p_input1 NUMBER
) RETURN NUMBER
    AS
BEGIN
    RETURN p_input1 * 2;
END;
/

SELECT
    SUM(fn1(ROWNUM) )
FROM
    dual
CONNECT BY
    level <= 2000000;

-----------------------------------------------------

WITH
    FUNCTION fn1 (
        p_input1 NUMBER
    ) RETURN NUMBER
        AS
    BEGIN
        RETURN p_input1 * 2;
    END;

SELECT
    SUM(fn1(ROWNUM) )
FROM
    dual
CONNECT BY
    level <= 2000000;

-----------------------------------------------------

CREATE OR REPLACE FUNCTION fn1 (
    p_input1 NUMBER
) RETURN NUMBER
    AS
PRAGMA UDF;
BEGIN
    RETURN p_input1 * 2;
END;
/

SELECT
    SUM(fn1(ROWNUM) )
FROM
    dual
CONNECT BY
    level <= 2000000;

-----------------------------------------------------

2 comments:

  1. Such A Great Informative article. Thanks for sharing it here. Also I created one website, Hope you will check it out also. This website is based on Sofa Reviews And Buying Guides. So check it out. Thanks. bestsofareview2020.wordpress.com

    ReplyDelete

About Me

I am Siva Jeevan.LK [LEARN | CODE | TRAIN | SHARE] Passionate to answer oracle SQL & PLSQL related questions. In my day to day job, I work with technologies including Oracle, Java, Python, MongoDB, talend and UNIX. I am passionate about "DATA", “SQL” , coding & training. In my spare time, I teach database technologies , ETL etc. I am very glad that you are reading my Profile, and I value your time as well as mine. Looking forward to see you in my videos at Siva Academy Passionate to answer oracle SQL & PLSQL related questions. You can contact me via My youtube channel (Siva Academy) or drop an email at siva.k.academy@gmail.com Happy to Learn & Help :-)

Total Pageviews