简体   繁体   中英

stored PL/sql function using select statement

Example i have a stored pl/sql

CREATE OR REPLACE PROCEDURE number( test in NUMBER )
........
// rest of code

isn't possible that i don't want run this execute

execute number(2);

i want run with

select * from number(2);

isn't possible to run stored pl/sql script with select statement to call the function instead of execute?

You can't execute a PROCEDURE from SQL; however, you can execute a FUNCTION from SQL.

First, redefine NUMBER as a FUNCTION:

CREATE OR REPLACE FUNCTION NUMBER(pTest IN NUMBER) RETURN NUMBER IS
  someValue NUMBER := pTest * 100;
BEGIN
  -- whatever
  RETURN someValue;
END;

Then execute it from a SELECT statement as

SELECT NUMBER(2) FROM DUAL;

Share and enjoy.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM