Write a script that creates and calls a stored procedure named insert_terms. Fir
ID: 3815597 • Letter: W
Question
Write a script that creates and calls a stored procedure named insert_terms. First, code a statement that creates a procedure that adds a new row to the TERMS table in the AP schema. To do that, this procedure should have two parameters: one for the terms_due_days column and another for the terms_description column. IF the value for the description column is NULL, the stored procedure should be able to create a default value for the description column based on the value of the due days column. For example, for a due days column of 120, the description column should have a default value of "Net due 120 days",. Then code a CALL statement that tests this procedure.
Explanation / Answer
CREATE OR REPLACE PROCEDURE INSERTTERMS (
in_terms_due_days IN AP.TERMS.terms_due_days %TYPE,
in_terms_description IN AP.TERMS.terms_description%TYPE
)
IS
BEGIN
INSERT
INTO AP.TERMS (terms_due_days,terms_description )
VALUES (in_terms_due_days,NVL(terms_description,concat(concat('Net due', in_terms_due_days),' days')));
COMMIT;
END;
/
EXECUTE AP.INSERTTERMS(120,NULL);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.