Home » SQL & PL/SQL » SQL & PL/SQL » plsql function/package
plsql function/package [message #635913] Sat, 11 April 2015 07:30 Go to next message
lexonsteel
Messages: 1
Registered: April 2015
Location: Briton
Junior Member

Hi Guru, I am a novice/learning oracle PLSQL using jdeveloper

 I have a very simple db table called TYPES with the following columns


PRICE: 100, 200, 300, 400

QUANTITY: 1,2,3,4

DURATION: 1,2,4,6,

CARS; VINTAGE, LIMO, LUXURY(including wedding transport) 


I want to calculate the following discounts based on the table above;

40% discount for duration of 2 or more days (DURATION)

20% discount for two or more cars(QUANTITY)

10% discount for wedding transport (CARS)


Many thanks




[Updated on: Sat, 11 April 2015 07:32]

Report message to a moderator

Re: plsql function/package [message #635914 is a reply to message #635913] Sat, 11 April 2015 08:03 Go to previous messageGo to next message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
Hi,

Welcome to the forum!

Please read and follow the OraFAQ Forum Guide and How to use [code] tags, to enable us to help you.

Why PL/SQL? Do it in SQL.

I see it to be simple mathematical calculations. I would use a CASE statement to check the DURATION and QUANTITY, and return the DISCOUNTED PRICE. The filter predicate will take care of the type of CAR.

But, it is not at all clear how are these values related? You need to provide a working test case. Create and insert statements. And show us your desired output based on the rules you explain.

Edit : Added Moderator bit

[Updated on: Sat, 11 April 2015 08:06]

Report message to a moderator

Re: plsql function/package [message #635915 is a reply to message #635913] Sat, 11 April 2015 08:10 Go to previous message
John Watson
Messages: 8931
Registered: January 2010
Location: Global Village
Senior Member
Welcome to the forum. Please read our OraFAQ Forum Guide and How to use [code] tags and make your code easier to read

As for your question, you need to start by providing the CREATE TABLE statement that you wrote; the INSERT statements for those rows; and example of what the outour should be. Then you need to show what queries you have tried so far. Then perhaps someone can help.

And note that you probably do not need PL/SQL for this, pure SQL will do.
Previous Topic: MultiByte Chars in a Column
Next Topic: Query Help
Goto Forum:
  


Current Time: Thu Apr 25 12:58:28 CDT 2024