Salut à tous

J'aimerais savoir si il serait mieux de faire un update sur des données plutôt que de les delete avant comme je le fais. Si oui, comment faire le script avec un insert et si les données existent, faire un update

Voici mon script pour le moment

Merci

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
DECLARE
   invalid_column_name          EXCEPTION;
   column_already_exist         EXCEPTION;
   table_does_not_exist         EXCEPTION;
   name_is_already_used         EXCEPTION;
   pub_synonym_not_exist        EXCEPTION;
   table_can_have_only_one_pk   EXCEPTION;
   unique_constraint            EXCEPTION;
   trigger_does_not_exist       EXCEPTION;
   constraint_exist             EXCEPTION;
   PRAGMA EXCEPTION_INIT (invalid_column_name, -904);
   PRAGMA EXCEPTION_INIT (column_already_exist, -1430);
   PRAGMA EXCEPTION_INIT (table_does_not_exist, -942);
   PRAGMA EXCEPTION_INIT (name_is_already_used, -955);
   PRAGMA EXCEPTION_INIT (pub_synonym_not_exist, -1432);
   PRAGMA EXCEPTION_INIT (table_can_have_only_one_pk, -2260);
   PRAGMA EXCEPTION_INIT (unique_constraint, -1);
   PRAGMA EXCEPTION_INIT (trigger_does_not_exist, -4080);
   PRAGMA EXCEPTION_INIT (constraint_exist, -2264);
BEGIN
	--DML010
	BEGIN
		DELETE address_type_definition WHERE address_type_id=1;
		DELETE address_type_definition WHERE address_type_id=2;
		INSERT INTO address_type_definition (address_type_id, description) VALUES (1, 'Physical');
		INSERT INTO address_type_definition (address_type_id, description) VALUES (2, 'Mailing');
 
		COMMIT;
	EXCEPTION
		WHEN unique_constraint THEN NULL;
		WHEN OTHERS THEN
			RAISE_APPLICATION_ERROR(-20101, 'DML010 ERROR SQLCODE = '||SQLCODE||' '||SQLERRM);
	END;
 
END;
/
SHOW ERRORS;