I'm working on a procedure that will declare a variable, take the value from a procedure that increments, and inserts that value along with other parameters into a table. I thought I had it all worked out, but then I got hit with PLS-00103: Encountered symbol "DECLARE" and Encountered symbol "end-of-file". I feel like I'm so close, so any help would be majorly appreciated! Thank you!
create or replace procedure Order_Create(date_order string, cust_id char, total float, employ_id number)
is
DECLARE NewKey;
BEGIN
NewKey := order_auto_inc.nextval;
UPDATE Progressive_Keys set Order_Limit = NewKey;
insert into ORDERS VALUES (Progressive_Keys.Order_Limit, to_date(date_order, 'yyyy-mm-dd'), cust_id, total, employ_id);
commit;
END;
Remove the
declareit's not needed in a stored procedures (as documented in the manual).A variable declaration needs a data type.
As the parameter
order_dateis supposed to be a date, it should be declared with that type.You can't access the column
order_limitoutside of a statement that uses the tableprogressive_keysso you need to use the variable in the insert statement as well.It's also good coding practice to always list the target columns in an INSERT statement (note that I just invented some column names for the
orderstable you will have to adjust them to reflect the real names in your table)The UPDATE looks a bit strange as it will update all rows in the thable
progressive_keysnot just one row.