2
votes

I have little knowledge on oracle. I tried to create a function like below.

CREATE OR REPLACE FUNCTION "BOOK"."CONVERT_TO_WORD" (totpayable IN NUMBER) RETURN VARCHAR
AS
  totlength   NUMBER;
  num VARCHAR2(14);

  word VARCHAR2(70);
  word1 VARCHAR2(8);
 BEGIN

   SELECT LENGTH(totpayable) INTO totlength FROM dual;

   WHILE totlength>0
       LOOP
           SELECT SUBSTR(totpayable,totlength,1) INTO num FROM dual;
           IF num='-' THEN
           word1:='(Excess)';
           END IF;
           IF num='0' THEN
           word1:='Zero';
           END IF;
           IF num='1' THEN
           word1:='One';
           END IF;
           IF num='2' THEN
           word1:='Two';
           END IF;
           IF num='3' THEN
           word1:='Three';
           END IF;
           IF num='4' THEN
           word1:='Four';
           END IF;
           IF num='5' THEN
           word1:='Five';
           END IF;
           IF num='6' THEN
           word1:='Six';
           END IF;
           IF num='7' THEN
           word1:='Seven';
           END IF;
           IF num='8' THEN
           word1:='Eight';
           END IF;
           IF num='9' THEN
           word1:='Nine';
           END IF;
           word:=word1||' '||word;
           totlength:=totlength-1;
       END LOOP;
RETURN word;

END ;

when I try to execute it, I am getting errors as below:

ORA-01031: insufficient privileges

01031.00000 - "insufficient privileges"

*Cause: An attempt was made to change the current username or password without the appropriate privilege. This error also occurs if attempting to install a database without the necessary operating system privileges. When Trusted Oracle is configure in DBMS MAC, this error may occur if the user was granted the necessary privilege at a higher label than the current login.

I have given privileges to the user using this command:

grant all privilege to book;

2

2 Answers

4
votes

use grant create session to book; and then create the procedure

4
votes

grant create procedure to book;