Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: stored proc vs plsql: question

RE: stored proc vs plsql: question

From: Tim Onions <tim.onions_at_speechmachines.com>
Date: Mon, 11 Dec 2000 09:00:48 -0000
Message-Id: <10707.124165@fatcity.com>


Kate

I'll take a crack at this as I've seen no replies to the list so far.

The syntax is:

create or replace procedure a
as

    jobnum dba_jobs.job%TYPE;
    CURSOR c1 is
 SELECT job from dba_jobs;
BEGIN
    OPEN c1;
    LOOP -- process each row one at a time

     FETCH c1 INTO jobnum;
     EXIT WHEN c1%NOTFOUND;

-- the c1%NOTFOUND condition evaluates
-- to TRUE when FETCH finds no more rows
/* run the job */ DBMS_JOB.RUN (jobnum);

    END LOOP;
    CLOSE c1;
    COMMIT;
END;
/

Which works for on my test db when run as SYS. When run as anybody else it fails because DBA_JOBS is not explicitly granted to other DBAs but is granted via the DBA role (I think). This is a common bug bear between anonymous PL/SQL and procedures - PL/SQL can accept object privs granted via roles, procedures cannot. I guess the easy solution is to explicitly grant SELECT on DBA_JOBS to whoever.

HTH -----Original Message-----
From: Kate Monro [mailto:KMonro_at_extend.com] Sent: 08 December 2000 23:31
To: Multiple recipients of list ORACLE-L Subject: stored proc vs plsql: question

I'm not so hot with the programming concepts, so does someone mind explaining to me what I have to chnage in order to make thie following plsql block into a stroed proc? I believe it's the DECLARE statement that is wrong. I thought I could just add the following at the beginning: CREATE OR REPLACE PROCEDURE runjobs_proc AS

DECLARE
    jobnum dba_jobs.job%TYPE;
    CURSOR c1 is

        SELECT job from dba_jobs;
BEGIN
    OPEN c1;

    LOOP	  -- process each row one at a time
    	FETCH c1 INTO jobnum;
    	EXIT WHEN c1%NOTFOUND;

-- the c1%NOTFOUND condition evaluates
-- to TRUE when FETCH finds no more rows
/* run the job */ DBMS_JOB.RUN (jobnum);

    END LOOP;
    CLOSE c1;
    COMMIT;
END;
/

thanks
K

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Kate Monro
  INET: KMonro_at_extend.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
Received on Mon Dec 11 2000 - 03:00:48 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US