Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Call stored Function from SQL statement?
On Mon, 18 Jan 1999 16:24:35 GMT, adrianh_at_globalnet.co.uk (Adrian
Harrison) wrote:
>I have a stored function with several parameters - similar to below
>
>/////////////////////////////////////////////////////////////////////////////////////////////////////
>CREATE OR REPLACE FUNCTION sum_nums (a IN NUMBER, b IN NUMBER, c IN NUMBER) RETURN number
> IS
> BEGIN
> RETURN a+b+c;
> END;
>/////////////////////////////////////////////////////////////////////////////////////////////////////
>
>Is it possible to call this from a SQL statement?
>
>Something like -
>
> select * from sum_nums (1,5,7);
>
>The parameters passed will be actual field values from a table?
>
>Any ideas
>
>thanks
>
>adrian harrison
>
Well, not exactly.
If you have table T1 with fields f1, f2, f3, then you can do the following:
select sum_nums(f1, f2, f3) from T1;
You'll get the sum of the 3 fields for each row.
Hope this helps,
Nuno Guerreiro
"The art of arts, the glory of expression and the sunshine that lights the light of letters is simplicity"
Walt Whitman Received on Mon Jan 18 1999 - 11:06:08 CST