If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > 9i XML extraction in "before" triggers

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-29-03, 02:34
javauserid javauserid is offline
Registered User
 
Join Date: May 2003
Posts: 1
Arrow 9i XML extraction in "before" triggers

Can xml.extract be done from a xmltype "pseudo-field" in a "before" trigger?

PLZ help me with the "before" trigger to replace the "after" trigger:
THANKS in advance!]

<<Fired by an insertion of NULL field values except for the last xmltype(CLOB)>>

***TRIGGER1 **************************
TRIGGER "SEG"."TIPOREPORTE"
BEFORE INSERT
ON "SEG"."TTIPOREPORTE"
FOR EACH ROW WHEN (NEW.PK IS NULL)
DECLARE
NPK NUMBER(4);
NFECHA DATE;
BEGIN
SELECT (NVL(MAX(PK),0)+1) INTO NPK FROM "SEG"."TTIPOREPORTE";
SELECT SYSDATE INTO NFECHA FROM DUAL;
:NEW.PK:=NPK;
:NEW.FECHA:=NFECHA;
END;

******* TRIGGER2 ****************
TRIGGER "SEG"."TIPOREPORTEAFTER"
AFTER INSERT
ON "SEG"."TTIPOREPORTE"
DECLARE
NPK NUMBER(4);
NNOMBRE VARCHAR2(256);
NTITULO VARCHAR2(256);
NENCABEZADO VARCHAR2(256);
NAUTOR VARCHAR2(256);
BEGIN
SELECT (NVL(MAX(PK),0)) INTO NPK FROM "SEG"."TTIPOREPORTE";
SELECT (NVL(XR.XMLTIPOREPORTE.extract('/report/@name')||'','Sin Nombre')) INTO NNOMBRE FROM "SEG"."TTIPOREPORTE" XR WHERE PK = NPK;
SELECT (NVL(XR.XMLTIPOREPORTE.extract('/report/@title')||'','Sin Título')) INTO NTITULO FROM "SEG"."TTIPOREPORTE" XR WHERE PK = NPK;
SELECT (NVL(XR.XMLTIPOREPORTE.extract('/report/headers/section/field/text/text()').getStringVal(),'Sin Encabezado')) INTO NENCABEZADO FROM "SEG"."TTIPOREPORTE" XR WHERE PK = NPK;
SELECT (NVL(XR.XMLTIPOREPORTE.extract('/report/@author')||'','Desconocido')) INTO NAUTOR FROM "SEG"."TTIPOREPORTE" XR WHERE PK = NPK;
UPDATE "SEG"."TTIPOREPORTE" SET
NOMBRE=NNOMBRE,
TITULO=NTITULO,
ENCABEZADO=NENCABEZADO,
AUTOR=NAUTOR
WHERE PK =NPK;
END;
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On