How I can use Exception of Oracle 8i in Procedure
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: How I can use Exception of Oracle 8i in Procedure

  1. #1
    Join Date
    Oct 2003
    Location
    Kuwait
    Posts
    1

    Question How I can use Exception of Oracle 8i in Procedure

    Hi,,
    I have created the following procedure using ORACLE 8i. and am fresh working on ORACLE. am trying to use a exception handler (built in) one.

    but always I keep getting an invalid compilation.

    Please advice
    Create Or replce ....etc
    (UserID IN int,DeptID IN VARCHAR2, ReturnedValue OUT INT)
    IS
    KeepLooping int;
    DeptIDValue int;
    ErrHandler int;
    DeptID2 int;

    BEGIN
    KeepLooping := 1;
    WHILE KeepLooping <> 0 LOOP
    DeptIDValue := TO_NUMBER(SUBSTR(DeptID,1,INSTR(DeptID,';') - 1));
    DeptID2 := SUBSTR(DeptID,INSTR(DeptID,';')+1,LENGTH(DeptID));

    IF INSTR(DeptID2,';') <> 0 THEN
    KeepLooping := 1;
    ELSE
    KeepLooping := 0;
    -- Insert user departments.
    INSERT INTO tbl_User_Dept(UserID,DeptID) VALUES(UserID,DeptIDValue);
    -- the error going in the following line
    EXCEPTION
    WHEN PROGRAM_ERROR THEN
    --ROLLBACK;
    ReturnedValue := 0;
    END;

    END IF;
    END LOOP;
    COMMIT;
    ReturnedValue := 1; -- 1 = true
    END;

  2. #2
    Join Date
    Jun 2000
    Location
    Madrid, Spain
    Posts
    7,447
    well this is basics...

    PL/SQL has this structure

    BEGIN
    .......
    .........
    ..........
    EXCEPTION
    ......
    .........
    .............
    END;
    /


    what you need to add is after your while loop a begin and end

    begin
    while blah blah
    loop
    begin
    ...
    ...
    exception
    ...
    ..
    end;
    end loop;
    end;
    /

Posting Permissions

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



Click Here to Expand Forum to Full Width