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 > Using cursors in PL/SQL

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-27-03, 18:37
jaba1979 jaba1979 is offline
Registered User
 
Join Date: Sep 2003
Location: Argentina
Posts: 4
Red face Using cursors in PL/SQL

How I have to do to define and use a cursor?
I need to modify a value in a table, but this is inside the trigger. So I get a mutant table.
I think that creating a temporary table and using a cursor for fetching its values I can solve the problem.
Another idea?

CREATE TRIGGER td_eq before delete ON eq FOR EACH ROW
BEGIN
INSERT INTO tmp_eq VALUES ( : old.NroEq, : old.Anio)
END;

CREATE TRIGGER td_eq1 before delete ON eq
DECLARE Y NUMBER;
Act NUMBER;
CURSOR C IS SELECT NroEq FROM eq
BEGIN
OPEN C;
FETCH C INTO Y,
WHILE C%found LOOP
SELECT Act INTO Act FROM eq WHERE NroEq = Y;
IF Act = 1 THEN
/*to do something*/
END IF;
FETCH C INTO Y
END LOOP;
DELETE FROM tmp_eq;
END;


Besides, I have another problem:

In the body of a trigger o stored procedure I write the following statement

update Table_P
set Act = 0
where Table_P.N= X;

But the previous code do not update that attribute (Act) in Table_P

What's the problem?

Last edited by jaba1979; 09-27-03 at 18:39.
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