-1

I created following procedure to remove item from allitems table by itemid, but procedure doesn't work as I wan,t. It Remove all items.

procedure DeleteItem(itemid in number) is
  begin
   delete from allitems where itemid=itemdid;
   commit;
  end;
  • Don't name your parameters the same as a column in the table. –  Feb 06 '17 at 09:22
  • Yes, Thank you for helping –  Feb 06 '17 at 09:41
  • As a general rule, [do not put a `COMMIT` statement in a procedure](http://stackoverflow.com/a/41998936/1509264). If the data needs `COMMIT`ing then it should be done from where the procedure is called allowing you to bundle multiple procedure calls into a single transaction and `COMMIT` or `ROLLBACK` them all in one go. – MT0 Feb 06 '17 at 11:18

1 Answers1

0

I know its not fashionable to have strict naming standards but they honestly help. Name your parameters prefixed with 'p_' so your code becomes;

create or replace procedure DeleteItem(itemid_in in number) is
begin
  delete from allitems where itemid = itemid_in;
  commit;  
end;  

I may not agree with all of it but take a look at Steven Feuerstein's take on this - https://community.oracle.com/servlet/JiveServlet/downloadBody/1007838-102-1-144760/PLSQL%20Naming%20Conventions%20and%20Coding%20Standards.pdf

BriteSponge
  • 1,034
  • 9
  • 15