I am doing my work in Oracle. In SQL Developer, create a procedure named TAX_COS
ID: 3798407 • Letter: I
Question
I am doing my work in Oracle.
In SQL Developer, create a procedure named TAX_COST_SP using the shoppers state and subtotal values. If the state isnt listed in the table, no tax is added. The state and the subtotal are the inputs to the procedure, and the tax amount should be returned. BB_TAX is table that contains state = VA and taxrate = .45. So far the following is what I have:
CREATE OR REPLACE PROCEDURE TAX_COST_SP
(p_state IN VARCHAR2,
p_subtot IN NUMBER,
p_total_tax OUT NUMBER)
IS
BEGIN
SELECT taxrate * p_subtot
INTO p_total_tax
FROM BB_TAX
WHERE IDSTATE = p_state;
END;
When I run the following code I receive an invalid number error:
DECLARE
lv_total_tax NUMBER(4,3);
BEGIN
TAX_COST_SP('VA',100, lv_total_tax);
DBMS_OUTPUT.PUT_LINE('Calculated tax is $'|| lv_total_tax);
END;
What am I doing wrong?
Explanation / Answer
Invalid number error occurs when we try to convert string into number. So please check whether 'taxrate' is defined as varchar or number in table BB_TAX
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.