Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

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, 03: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

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