tags:

views:

58

answers:

1

I would like to create a function that can be used in the where part of a select statement. Like this:

select 'x' from table where addNumber(4,3)=7;

I know how to do this in MS SQL, but I would like to do this Oracle SQL. How can I do this?

+1  A: 

You need to write a PL/SQL function...

CREATE OR REPLACE FUNCTION addNumber(firstParam  IN NUMBER,
                                     secondParam IN NUMBER)
RETURN NUMBER
IS 
BEGIN
   RETURN firstParam + secondParam;
END;
/

...run this into the scheam you're using (probably using SQL*Plus) and then call it as you did in your SQL statement above.

cagcowboy
Thanks for the quick answer
gyurisc