CREATE OR REPLACE PROCEDURE InsertRepair
(pIdSerial IN REPAIR.SERIALID%TYPE,
pIdUser IN REPAIR.USERID%TYPE,
pDateSTAMP IN REPAIR.STAMP%TYPE,
pIdFailure IN FAILURE.ID%TYPE,
pIDCause IN CAUSE.ID%TYPE,
pIDACTION IN ACTION.ID%TYPE,
pIDOWNREP IN OWNREP.ID%TYPE,
pRepMsgName IN REPMSG.name%TYPE,
pBatchName IN BATCH.name%TYPE, -- Repere topo
pFailName IN FAILREF.name%TYPE,
pBatchRef IN BATCH.REFERENCE%TYPE,
pPasdetest IN OWNREP.DESCRIPT%TYPE,
pIDRepairToReturn OUT REPAIR.ID%TYPE
) IS
IdRepair REPAIR.ID%TYPE := to_number(NULL) ;
IDFailRef failref.ID%TYPE := to_number(NULL) ;
IdRepMsg REPMSG.ID%TYPE := to_number(NULL) ;
IdBatch BATCH.ID%TYPE := to_number(NULL) ;
sFailtype FAILTYPE.NAME%TYPE ;
IdCauseCat REPAIR.CAUSECATID%TYPE;
BEGIN
-- Retrouver le type de la FAILURE pour inserer le meme
-- Sinon on prend 'PART'
begin
select FAILTYPE.NAME into sFAilTYPE
FROM FAILURE, FAILTYPE, FAILREF
WHERE FAILREF.FAILTYPEID = FAILTYPE.ID
AND FAILURE.FAILREFID = FAILREF.ID
AND FAILURE.ID = pIdFAILURE ;
Exception WHEN no_data_found THEN
sFailtype := 'PART' ;
end ;
-- Creation ou retrouve la defaillance si pas de defaut -none-
InsertFailRef( nvl(pFailName,'-none-'), sFailtype, IDFailRef ) ;
-- Insertion ou retrouve BATCH
IF pBatchName IS NOT NULL OR pBatchRef IS NOT NULL THEN
InsertBatch (pBatchName,pBatchRef, IdBatch) ;
END IF ;
DBMS_OUTPUT.PUT( ' ' || 'Pas de test =' || pPasdetest ) ;
DBMS_OUTPUT.NEW_LINE ;
-- Insertion ou rtrouve PASDETEST
-- IF pPasdetest IS NOT NULL THEN
INSERT INTO OWNREP (ID,DESCRIPT)
VALUES (pIDOWNREP,pPasdetest);
-- END IF ;
-- Insertion ou rtrouve REPMSG
IF pRepMsgName IS NOT NULL THEN
InsertRepMsg (pRepMsgName, IdREPMSG ) ;
END IF ;
begin
SELECT CAUSE.CAUSECATID into IdCauseCat
FROM CAUSE
WHERE CAUSE.ID = pIdCause;
Exception WHEN no_data_found THEN
IdCauseCat := 1 ;
end ;
-- Creation de la reparation.
IdRepair := bd_ident ;
INSERT INTO REPAIR
(ID , FAILREFID ,FAILUREID
, STAMP ,STATUS ,USERID
, CAUSEID ,ACTIONID ,REPMSGID
, OWNREPID ,PARTDATAID
,SERIALID, CAUSECATID )
SELECT IdRepair, IDFailRef, pIdFailure
,pDateStamp, 0 , pIDUSER
,pIDCAUSE, pIDACTION, IdREPMSG
,pIDOWNREP , IdBatch
,pIdSerial, IdCauseCat
FROM DUAL;
pIDRePairToReturn := IdRepair ;
END;
/
Partager