Comment utiliser des variables dans un Oracle de déclenchement

Je suis en train de créer un déclencheur pour mettre à jour un vérifier la colonne de hachage. Il n'a pas à être des RH, mais pour le sql puzzle ce soit les ressources humaines, la table est:

   DESC SINERS
Name      Null     Type         
--------- -------- ------------ 
LAST_NAME          VARCHAR2(20) 
SIN  NOT NULL NUMBER(9)    
VFY            NUMBER(2)    

le puzzle est délicate, et nécessite un peu de code.

La plupart des systèmes de paie est intégré dans le contrôle de validité pour le social
numéro d'assurance. L'exemple suivant illustre comment manuellement
vérifier la validité d'un numéro d'assurance sociale: les Assurances Sociales
Numéro: 123 456 782 Supprimer le chiffre de contrôle (le dernier chiffre): 2 Extrait
les 2ème, 4ème, 6ème et 8ème chiffres: 2 4 6 8 Doubler: 4 8 12 16 Ajouter
les chiffres ensemble: 4 + 8 + 1 + 2 + 1 + 6 = 22 Ajouter les 1ère, 3ème, 5ème
et 7 chiffres: 1 + 3 + 5 + 7 = 16 TOTAL: 38

J'ai juste fait ce tableau pour simuler comment attraper une variable dans l'instruction update ou insert, calculer un hash... puis jeter la variable de retour dans la même table.

c'est à dire ... l'utilisateur exécute ce :

insert into siners (last_name, sin) values (smith, 111222333);

or 

update siners set sin = 222333444 where last_name = 'smith';

J'ai regardé sur le web pour des exemples de comment faire cela, mais il n'est pas clair.

Est-il un moyen facile de faire cela? une fonction peut-être?

D'abord, j'ai généré l'oracle sql code, --- je sous-chaîne de caractères de la merde hors de lui, mais il fonctionne.

SELECT NVL((NEXT_MULTI - TOTAL_SUM), 0) AS CHECK_VAL
FROM (
SELECT ((
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 1,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 2,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 3,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 4,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 5,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 6,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 7,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 8,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 9,1), 0) 
) + (  SUBSTR(SIN, 1, 1) + SUBSTR(SIN, 3, 1) + SUBSTR(SIN, 5, 1) + SUBSTR(SIN, 7, 1)))
"TOTAL_SUM",  
CASE WHEN SUBSTR(((
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 1,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 2,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 3,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 4,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 5,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 6,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 7,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 8,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 9,1), 0) 
) + (  SUBSTR(SIN, 1, 1) + SUBSTR(SIN, 3, 1) + SUBSTR(SIN, 5, 1) + SUBSTR(SIN, 7, 1))), 2, 1) BETWEEN 1 AND 9 THEN ((10 - (SUBSTR(((
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 1,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 2,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 3,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 4,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 5,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 6,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 7,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 8,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 9,1), 0) 
) + (  SUBSTR(SIN, 1, 1) + SUBSTR(SIN, 3, 1) + SUBSTR(SIN, 5, 1) + SUBSTR(SIN, 7, 1))), 2, 1))) + ((
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 1,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 2,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 3,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 4,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 5,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 6,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 7,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 8,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 9,1), 0) 
) + (  SUBSTR(SIN, 1, 1) + SUBSTR(SIN, 3, 1) + SUBSTR(SIN, 5, 1) + SUBSTR(SIN, 7, 1)))) END AS NEXT_MULTI
FROM SINERS);

Deuxième, j'ai essayé de faire un code de déclenchement, et c'est là que je suis bloqué pour le moment.

J'ai essayé de créé le déclencheur avec SQL select, mais, il m'a donné une erreur, que je ne pouvais pas exécuter un select sur une ligne qui a été modifié. //Le déclencheur compilé amende, mais il recraché l'erreur quand j'ai couru un insert sur la table.

CREATE OR REPLACE TRIGGER CHK_VFY
AFTER INSERT OR UPDATE OF SIN ON SINERS
FOR EACH ROW 
DECLARE
LAST_ONE  NUMBER(1); 
TOTAL_SUM  NUMBER(2);  
NEXT_MULTI NUMBER(2);
CHECK_VAL  NUMBER(2);
BEGIN
SELECT T_SUM INTO TOTAL_SUM
FROM (
SELECT ((
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 1,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 2,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 3,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 4,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 5,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 6,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 7,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 8,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 9,1), 0) 
) + (  SUBSTR(SIN, 1, 1) + SUBSTR(SIN, 3, 1) + SUBSTR(SIN, 5, 1) + SUBSTR(SIN, 7, 1)))
"T_SUM" FROM SINERS );
SELECT LAST1 INTO LAST_ONE
FROM (
SELECT  SUBSTR(((
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 1,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 2,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 3,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 4,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 5,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 6,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 7,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 8,1), 0) +
NVL(SUBSTR( (SUBSTR(SIN, 2, 1)*2) || (SUBSTR(SIN, 4, 1)*2) || (SUBSTR(SIN, 6, 1)*2) || (SUBSTR(SIN, 8, 1)*2), 9,1), 0) 
) + (  SUBSTR(SIN, 1, 1) + SUBSTR(SIN, 3, 1) + SUBSTR(SIN, 5, 1) + SUBSTR(SIN, 7, 1))), 2, 1) LAST1 FROM SINERS);
IF LAST_ONE BETWEEN 1 AND 9 THEN 
NEXT_MULTI := (10 - LAST_ONE) + TOTAL_SUM ;
CHECK_VAL := (NEXT_MULTI - TOTAL_SUM);
ELSE 
CHECK_VAL := 0;
END IF;
UPDATE SINERS SET VFY = CHECK_VAL;
END;

Après un peu de recherche, sur ce site, et d'autres, j'ai essayé d'utiliser :nouveau.le péché de saisir la variable avant la mise à jour, mais n'avait pas de chance. il ne semble pas de mise à jour. Donc, j'ai laissé tomber dans le dbms_output.put_line( ' Updated Check Value = ' || CHECK_VAL ); pour essayer et vérifier si les variables étaient rassemblés. Je n'ai pas de sortie à partir du tout....

à l'aide de l' :nouveau.code variable.... Il compile bien, mais me demande de lier les variables. "la nouvelle" La valeur par défaut est null, mais j'ai essayé de jouer avec les variables comme je vois que certains reference new as new and old as old dans les exemples de ce genre.

CREATE OR REPLACE TRIGGER CAL_VFY
BEFORE INSERT OR UPDATE OF SIN ON SINERS
FOR EACH ROW 
DECLARE
SINNO NUMBER(9);
LAST_ONE  NUMBER(2); 
TOTAL_SUM  NUMBER(2);  
NEXT_MULTI NUMBER(2);
CHECK_VAL  NUMBER(2);
BEGIN
SINNO := :NEW.SIN;
dbms_output.put_line( 'side sin = ' || sinno );
LAST_ONE := SUBSTR(((
NVL(SUBSTR( (SUBSTR(SINNO, 2, 1)*2) || (SUBSTR(SINNO, 4, 1)*2) || (SUBSTR(SINNO, 6, 1)*2) || (SUBSTR(SINNO, 8, 1)*2), 1,1), 0) +
NVL(SUBSTR( (SUBSTR(SINNO, 2, 1)*2) || (SUBSTR(SINNO, 4, 1)*2) || (SUBSTR(SINNO, 6, 1)*2) || (SUBSTR(SINNO, 8, 1)*2), 2,1), 0) +
NVL(SUBSTR( (SUBSTR(SINNO, 2, 1)*2) || (SUBSTR(SINNO, 4, 1)*2) || (SUBSTR(SINNO, 6, 1)*2) || (SUBSTR(SINNO, 8, 1)*2), 3,1), 0) +
NVL(SUBSTR( (SUBSTR(SINNO, 2, 1)*2) || (SUBSTR(SINNO, 4, 1)*2) || (SUBSTR(SINNO, 6, 1)*2) || (SUBSTR(SINNO, 8, 1)*2), 4,1), 0) +
NVL(SUBSTR( (SUBSTR(SINNO, 2, 1)*2) || (SUBSTR(SINNO, 4, 1)*2) || (SUBSTR(SINNO, 6, 1)*2) || (SUBSTR(SINNO, 8, 1)*2), 5,1), 0) +
NVL(SUBSTR( (SUBSTR(SINNO, 2, 1)*2) || (SUBSTR(SINNO, 4, 1)*2) || (SUBSTR(SINNO, 6, 1)*2) || (SUBSTR(SINNO, 8, 1)*2), 6,1), 0) +
NVL(SUBSTR( (SUBSTR(SINNO, 2, 1)*2) || (SUBSTR(SINNO, 4, 1)*2) || (SUBSTR(SINNO, 6, 1)*2) || (SUBSTR(SINNO, 8, 1)*2), 7,1), 0) +
NVL(SUBSTR( (SUBSTR(SINNO, 2, 1)*2) || (SUBSTR(SINNO, 4, 1)*2) || (SUBSTR(SINNO, 6, 1)*2) || (SUBSTR(SINNO, 8, 1)*2), 8,1), 0) +
NVL(SUBSTR( (SUBSTR(SINNO, 2, 1)*2) || (SUBSTR(SINNO, 4, 1)*2) || (SUBSTR(SINNO, 6, 1)*2) || (SUBSTR(SINNO, 8, 1)*2), 9,1), 0) ) + 
(  SUBSTR(SINNO, 1, 1) + SUBSTR(SINNO, 3, 1) + SUBSTR(SINNO, 5, 1) + SUBSTR(SINNO, 7, 1))), 2, 1); 
TOTAL_SUM := ((
NVL(SUBSTR( (SUBSTR(SINNO, 2, 1)*2) || (SUBSTR(SINNO, 4, 1)*2) || (SUBSTR(SINNO, 6, 1)*2) || (SUBSTR(SINNO, 8, 1)*2), 1,1), 0) +
NVL(SUBSTR( (SUBSTR(SINNO, 2, 1)*2) || (SUBSTR(SINNO, 4, 1)*2) || (SUBSTR(SINNO, 6, 1)*2) || (SUBSTR(SINNO, 8, 1)*2), 2,1), 0) +
NVL(SUBSTR( (SUBSTR(SINNO, 2, 1)*2) || (SUBSTR(SINNO, 4, 1)*2) || (SUBSTR(SINNO, 6, 1)*2) || (SUBSTR(SINNO, 8, 1)*2), 3,1), 0) +
NVL(SUBSTR( (SUBSTR(SINNO, 2, 1)*2) || (SUBSTR(SINNO, 4, 1)*2) || (SUBSTR(SINNO, 6, 1)*2) || (SUBSTR(SINNO, 8, 1)*2), 4,1), 0) +
NVL(SUBSTR( (SUBSTR(SINNO, 2, 1)*2) || (SUBSTR(SINNO, 4, 1)*2) || (SUBSTR(SINNO, 6, 1)*2) || (SUBSTR(SINNO, 8, 1)*2), 5,1), 0) +
NVL(SUBSTR( (SUBSTR(SINNO, 2, 1)*2) || (SUBSTR(SINNO, 4, 1)*2) || (SUBSTR(SINNO, 6, 1)*2) || (SUBSTR(SINNO, 8, 1)*2), 6,1), 0) +
NVL(SUBSTR( (SUBSTR(SINNO, 2, 1)*2) || (SUBSTR(SINNO, 4, 1)*2) || (SUBSTR(SINNO, 6, 1)*2) || (SUBSTR(SINNO, 8, 1)*2), 7,1), 0) +
NVL(SUBSTR( (SUBSTR(SINNO, 2, 1)*2) || (SUBSTR(SINNO, 4, 1)*2) || (SUBSTR(SINNO, 6, 1)*2) || (SUBSTR(SINNO, 8, 1)*2), 8,1), 0) +
NVL(SUBSTR( (SUBSTR(SINNO, 2, 1)*2) || (SUBSTR(SINNO, 4, 1)*2) || (SUBSTR(SINNO, 6, 1)*2) || (SUBSTR(SINNO, 8, 1)*2), 9,1), 0) 
) + (  SUBSTR(SINNO, 1, 1) + SUBSTR(SINNO, 3, 1) + SUBSTR(SINNO, 5, 1) + SUBSTR(SINNO, 7, 1))); 
IF LAST_ONE BETWEEN 1 AND 9 THEN 
NEXT_MULTI := (10 - LAST_ONE) + TOTAL_SUM ;
CHECK_VAL := (NEXT_MULTI - TOTAL_SUM);
ELSE 
CHECK_VAL := 0;
END IF;
CASE 
WHEN INSERTING THEN
UPDATE SINERS SET VFY = CHECK_VAL WHERE SIN = :NEW.SIN;
dbms_output.put_line( 'New Check Value = ' || CHECK_VAL );
WHEN UPDATING THEN
UPDATE SINERS SET VFY = CHECK_VAL WHERE SIN = :NEW.SIN;
dbms_output.put_line( ' Updated Check Value = ' || CHECK_VAL );
END CASE;
END;

Si vous avez une pensée sur la façon d'aller à ce sujet, je suis preneuse....

Merci pour votre aide!

  • Si la catégorie est liée à la clientèle dans une autre table déjà, pourquoi vous voulez copier ce lien dans cette table et de le maintenir en deux endroits?
  • Tout d'abord, lisez ce - stackoverflow.com/questions/how-to-ask . Où est-ce que la "division" de la colonne? S'il vous plaît montrer TOUS les schémas de table.
  • En fait, tout ce que je veux c'est avoir un déclencheur calculer la troisième colonne lorsqu'un utilisateur de mettre à jour ou d'insérer les deux premiers. J'ai essayé d'utiliser l' :nouveau. avec la mise à jour, mais il ne fonctionne pas. Il se compile sans erreur, mais ne fonctionne pas. C'est juste un exemple.
InformationsquelleAutor Tom | 2013-05-06