Tuesday 15 January 2013

Producing a report with a stored SQL function -



Producing a report with a stored SQL function -

i trying produce study calculates discount applied order using stored function in oracle 12c. have table, orders column o_id. each line of order separate order_line table, having o_id, ol_quantity, , ol_price. if order on $100, discount of $10 applied order.

i have created stored function, compiles, when seek run function error:

error(10,1): pls-00103: encountered symbol "final_cost" when expecting 1 of following: * & - + / @ mod remainder rem <an exponent (**)> , or || multiset

here function:

create or replace function discountsreport (order_id in real) homecoming real percent real; final_cost real; beingness select sum(order_line.ol_quantity * order_line.ol_price) total order_line o_id = order_id; if total >= 100 final_cost = 90; homecoming final_cost; end;

and code run is:

var cost number; execute :cost := discountsreport(1); print cost;

your "if" statement absolutely incorrect. take @ documentation: if-then-else

sql stored-functions oracle12c

No comments:

Post a Comment