Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Create or Replace Function

Dj SteeleSep 4 2018 — edited Sep 5 2018

Good Afternoon Community,

I am trying to create a Function to Get a Tax Rate but am getting an Error on Compiling the Function: I am trying to add the Local Rate and State Rate to get the Final "Tax_Rate"

create or replace function Get_Tax_Rate(Receipt_Date IN Date)

Return Number IS

Tax_Rate Number := local_tax_rate + state_tax_rate;

local_tax_rate number;

state_tax_rate number;

Begin

select local.tax_rate,

   (Select state.tax\_rate

    from tax\_rates state

    where upper(state.tax\_type)='STATE')

into local_tax_rate,

 state\_tax\_rate                                           

from tax_rates local

where upper(local.tax_type) = 'LOCAL'

and local.effective_date = (select max(b.effective_date)

                        from tax\_rates b

                        where local.tax\_type = b.tax\_type

                        and b.effective\_date \<= Receipt\_Date);

Return(Tax_Rate);

End;

-----------------------------------------------------------------------------------------------------------------------------------

The Select Statement Returns This

pastedImage_0.png

Thanks in Advance

DSteele41

This post has been answered by mathguy on Sep 4 2018
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 3 2018
Added on Sep 4 2018
32 comments
1,038 views