Reputation: 9
For homework im suppose to print out payment_total and invoice_total for a procedure with a parameter is vendor_id. It compiled but it said the declared was wrong im not sure if my syntax is wrong or what the issue is.
Here is my code:
CREATE OR REPLACE PROCEDURE vn_payment(vendorID in number)
IS
DECLARE
payment_total vendors.vendor_id%type;
invoice_total vendors.vendor_id%type;
BEGIN
Select vendor_id from vendors
where vendor_id = vendorID;
DBMS_OUTPUT.PUT_LINE('payment total:' || payment_total || 'and invoice total'
|| invoice_total);
END;
Upvotes: 0
Views: 56
Reputation: 168681
You don't need the DECLARE
keyword in a procedure and you also need to SELECT ... INTO ...
:
CREATE OR REPLACE PROCEDURE vn_payment(vendorID in number)
IS
payment_total vendors.vendor_id%type;
invoice_total vendors.vendor_id%type;
BEGIN
Select vendor_id, vendor_id
INTO payment_total, invoice_total
from vendors
where vendor_id = vendorID;
DBMS_OUTPUT.PUT_LINE(
'payment total:' || payment_total || 'and invoice total'|| invoice_total
);
END;
/
However, you probably want to select the totals and not the id.
Upvotes: 2