views:

101

answers:

1

How to make procedure that update 5 table's ?

for ex:

....update table1 set field1 = .......

....update table2 set field2 = .......

....update table3 set field3 = .......

in oracle 10g - pl/sql

+4  A: 
CREATE OR REPLACE MY_PROCEDURE ( [parameter(s) here...]) AS
BEGIN

  UPDATE TABLE_1 SET...;
  UPDATE TABLE_2 SET...;
  UPDATE TABLE_3 SET...;
  UPDATE TABLE_4 SET...;
  UPDATE TABLE_5 SET...;

END;

If you don't need parameters, then you can either run them as an anonymous procedure:

BEGIN

  UPDATE MEN SET fname = 'X';
  UPDATE WORK SET fname = 'Y';

END;

...or execute each procedure individually. You could just put the UPDATE statements, line by line, in a file & run it.

OMG Ponies
thank's for the help !, what i need to put in parameter ? - can i get sample ? and how i run this procedure ? (i new in database)
Gold
If you don't need any parameters, you can omit the whole `( [parameter(s) here...])` bit.
Jeffrey Kemp