Home » SQL & PL/SQL » SQL & PL/SQL » Function
Function [message #187627] Mon, 14 August 2006 13:58 Go to next message
eqqqqqq
Messages: 30
Registered: August 2006
Member
Hi! I need some help..
I need to create a function, counting the total sum of an invoice_nr and returning the total sum. Same Invoice_nr might have several ISBN... so do I need to loop through the rows???


CREATE OR REPLACE FUNCTION func1(INVOICE_NR IN number)
RETURN number
AS
temp number;
BEGIN
temp:=Select sum(o.quantity * b.price)
from IOI o, BOOK b
WHERE O.invoice_nr=INVOICE_NR
AND o.isbn=b.isbn;
RETURN temp;
END func1;
Re: Function [message #187628 is a reply to message #187627] Mon, 14 August 2006 14:04 Go to previous message
joy_division
Messages: 4643
Registered: February 2005
Location: East Coast USA
Senior Member
Proper syntax is:

SELECT whatever
INTO variable
FROM wherever
WHERE clause;

Then you can return the variable.
Previous Topic: insert approach
Next Topic: raise_application_error function and unicode problem
Goto Forum:
  


Current Time: Fri Dec 09 05:36:56 CST 2016

Total time taken to generate the page: 0.19569 seconds