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?
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?
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.