Results 1 to 1 of 1
  1. #1
    Join Date
    Sep 2003
    Location
    Argentina
    Posts
    4

    Red face Unanswered: 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 19:39.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •