Throw, please, somebody an example of creation of procedure on change.

  • To change what when where and why? If you know that such a procedure is very strange that the answer is not obvious to you ... - Zowie
  • for example, to change the address (address) by the entered name (name) stored in the table Staff ... - AgerAnat

3 answers 3

I do not know oracle at all, but in mysql it is done something like this ...
Request

\d // --устанавливаем делиметр CREATE PROCEDURE updateAdress(IN username VARCHAR(50), IN newArdess VARCHAR(50)) --тип данных IN параметров должен совпадать с типом в таблице BEGIN UPDATE staff SET adress=newAdress WHERE name=username; END; // --подверждаем операцию \d ; --возвращаем стандартный деллиметр 

Now to call, for example from PHP ..

 // подключение... $username = 'Вася'; $newAdress = 'ул.Васильковская, д.10'; mysql_query("CALL updateAdress($username, $newAdress)"); //где username имя пользователя newAdress обновляемое значение //в данном случае мы обновляем адресс Васе... 

Important notes - in your particular example, the name should be either the primary key in order to avoid changing several entries at once, or some additional parameter should be added, in general, any update operation of single records should occur either by unique index , or by primary key or by unique composite index.

Once again, I didn’t do anything with oracle, maybe it’s done differently there ... (about procedures)

    You do not need a procedure, but a trigger. Trigger syntax for oracle:

     CREATE TRIGGER schema.trigger_name AFTER UPDATE ON schema.table_name pl/sql_block 

    Next - google in hand, see examples and write your own.

    • No, I need exactly the procedure) - AgerAnat
    • one
      "Procedures for change" does not happen. There is a trigger that calls a procedure. - minamoto
    • And how are you going to call the procedure without using a trigger? <br> By the way, do you need it? Wash you are trying to complicate your life ... - Zowie

    The @AlexWindHope in oracle is almost all but without a delimiter:

     CREATE OR REPLACE PROCEDURE change_address(name in varchar2(50), new_address in varchar2(100)) is BEGIN UPDATE staff SET adress=newAdress WHERE name=username; COMMIT; END; / 
    • I'll know, maybe someday it will come in handy :) - Zowie