I'm trying to create a package for an application on oracle APEX!!
Here's the code I used:
create or replace package customer_authentication
as
function customer_exists (p_email in varchar2) return boolean;
procedure insert_new_customer (
p_fullname in varchar2,
p_email in varchar2,
p_password in varchar2);
function customer_authentication_f (
p_username in varchar2 default null,
p_password in varchar2 default null)
return boolean;
end customer_authentication; --end of package specification
create or replace package body customer_authentication
as
function customer_exists (p_email in varchar2)
return boolean;
as
l_aux number;
begin
select id
into l_aux
from customer
where upper(email) = upper (p_email);
return true;
exception when no_data_found then return false;
end customer_exists;
function password_hashing (
p_username in varchar2,
p_password in varchar2)
return varchar2
as
l_password varchar2(4000);
l_salt varchar2(4000) := 'AA8V33PFKQHFZJ4T54HOATVML024FM';
begin
l_password := utl_raw.cast_to_raw(
dbms_obfuscation_toolkit.md5(
input_string => p_password ||
substr(l_sault, 10, 13) ||
p_username ||
substr(l_sault, 4, 10)
)
);
return l_password;
end password_hashing;
procedure insert_new_customer (
p_fullname in varchar2,
p_email in varchar2,
p_password in varchar2)
as
l_encrypted_password varchar(32);
begin
l_encrypted_password := password_hashing (upper(p_email), p_password);
insert into customer (fullname, email, encrypted_password)
values (p_fullname, lower(p_email), l_encrypted_password);
commit;
end insert_new_customer;
function customer_authentication_f (
p_username in varchar2,
p_password in varchar2)
return boolean
as
l_aux number; --boithitiki metablhth
l_encrypted_password varchar2(32)
begin
/* kryptografish toy password */
l_encrypted_password := password_hashing (
p_username => upper(p_username),
p_password => p_password );
select id
into l_aux
from customer
where upper(email)=upper(p_username)
and encrypted_password=l_encrypted_password;
return true;
exception
when no_data_found then return false;
end customer_authentication_f;
end customer_authentication; -- end of package body
I tried running it through the SQL Workshop (commands) but after pressing the "run" button, a pop up window came up with only a Submit button!! (?)
So, my question is: Is everything alright with the script? The error is just because I pushed submit without any given data??? :P
Thanx for your time...
Discuss This Question: 3  Replies