I am reading and thinking that a user (or any object) cannot be created within a procedure. Is that correct? I am new to
PL/ SQL, not programming, but do apologize.
I have a StdtTable (in SYS) with 3 columns: account, password, rowid.
I just want to read each row and create a user. This is what I have, does anyone have any idea's? The code is sloppy as I am stuck on the create. :-( Thank you. Oh, I am running this is SQLDeveloper.
CREATE OR REPLACE
PROCEDURE makeStudents
AS
-- declare all variables!
iReturnCode int:=0;
iNextRowId int:=0;
iCurrentRowId int:=0;
iLoopControl int :=13;
iRowId INT :=0;
vhELLO VARCHAR2 (30 CHAR) := 'HELLO';
vchACCOUNName varchar2(7):='';
vchPasswordNmbr varchar2(9):='';
BEGIN
SELECT iRowId into iNextRowId FROM SYS.STDTable;
-- Retrieve the first row
SELECT iRowId, STDAccount, STDPASSWORD INTO iCurrentRowId, vchACCOUNName,vchPasswordNmbr
FROM SYS.STDTABLE WHERE iRowId = iNextRowId;
/* EXCEPTION
WHEN NO_DATA_FOUND THEN
RETURN;*/
-- start the main processing loop.
WHILE iLoopControl > iNextRowId
LOOP
BEGIN
CREATE USER vchACCOUNName
IDENTIFIED BY vchPasswordNmbr
DEFAULT TABLESPACE STUDENTTABLESPACE
QUOTA 10M ON example
QUOTA 10M ON system;
-- processing.
SELECT iRowId into iNextRowId
FROM SYS.STDTable
WHERE iRowId > iCurrentRowId;
SELECT iRowId, STDAccount, STDPASSWORD INTO iCurrentRowId, vchACCOUNName,vchPasswordNmbr
FROM SYS.STDTABLE WHERE iRowId = iNextRowId;
/* EXCEPTION
WHEN NO_DATA_FOUND THEN
RETURN;*/
end;--begin in while
end loop;--in while
end;--procedure