Tuesday, May 14, 2019

How to write and call PL/SQL function in SQL script using WITH clause?

Example# 1:



WITH
FUNCTION voter(age NUMBER) Return VARCHAR2
IS
BEGIN
If(age > 18) THEN
RETURN 'Eligible for voting.';
ELSE
RETURN 'Not eligible for voting.';
END if;
END;
--

SELECT voter(19) FROM dual;
--

Output:

Eligible for voting. 

Note:

In this case PL/SQL function object not saved or created. We must write the function where we want to use. (See above example# 1.)

2 comments:

  1. Hey Guys, If you want to use this converter then you can easily convert your one file to other file;

    File to File Convertor

    ReplyDelete

Query to get Sales Order Customer details

  SELECT  ooha.order_number      ,  ooha.org_id      ,  ooha.sold_to_org_id bill_cust_account_id      ,  ooha.ship_to_org_id ship_to_site_us...