0

What is wrong with this procedure:

CREATE OR REPLACE
PROCEDURE add_user (pid IN NUMBER, plogin IN VARCHAR2, ppassword IN VARCHAR, pemail IN VARCHAR)
IS
BEGIN
  DECLARE encryptedpassword VARCHAR(255);
  SET encryptedpassword := MD5(ppassword);
  INSERT INTO account(id, login, password, email)
  VALUES (pid, plogin, encryptedpassword, pemail);
END add_user;

For me it's look ok, but I'm getting errors:

Error(6,3): PLS-00103: Encountered the symbol "INSERT" when expecting one of the following: begin function pragma procedure subtype type current cursor delete exists prior The symbol "begin" was substituted for "INSERT" to continue.

Error(8,13): PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following: ( begin case declare end exception exit for goto if loop mod null pragma raise return select update while with << continue close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe purge

My table account looks like this:

CREATE TABLE account 
(
  id NUMBER(6,0) PRIMARY KEY, 
  login VARCHAR2(16) NOT NULL, 
  password VARCHAR(255) NOT NULL,
  email VARCHAR(25) NOT NULL,
  register_data DATE,
  last_seen DATE,
  login_failed NUMBER(5,0)
);

Anybody, something?

demoo
  • 111
  • 2
  • 3
  • 11
  • 2
    Please don't use MD5 for hashing actual passwords. It [has significant flaws](https://en.wikipedia.org/wiki/MD5). – Ben May 30 '16 at 20:52
  • @Ben this is also not working: CREATE OR REPLACE PROCEDURE add_user (pid IN NUMBER, plogin IN VARCHAR2, ppassword IN VARCHAR, pemail IN VARCHAR) IS DECLARE encryptedpassword VARCHAR(255); BEGIN encryptedpassword := MD5(ppassword); INSERT INTO account(id, login, password, email) VALUES (pid, plogin, encryptedpassword, pemail); END add_user; – demoo May 30 '16 at 21:01
  • Remove the DECLARE... it's not required in compiled code - the `create or replace` is the declaration of the start of the block. – Ben May 30 '16 at 21:06
  • @Ben hmm weird "Error(5,24): PLS-00201: identifier 'MD5' must be declared" – demoo May 30 '16 at 21:16

0 Answers0