Please correct my code (Login Registration)
I need to return "-1" if username exixts and i need to return 1 if username is new and then insert values into table.
This procedure is for Registering UserName and Password For Login
--------------------------------------------------------------------------------------------------------------
CREATE OR REPLACE PROCEDURE debopriyo_savelogindetails
(
p_nameofuser debopriyo_logindetailstable.nameofuser%TYPE,
p_username debopriyo_logindetailstable.username%TYPE,
p_userpassword debopriyo_logindetailstable.userpassword%TYPE
)
IS
v_count number;
v_returncode number;
BEGIN
select count(t.username) into v_count from debopriyo_logindetailstable t;
if(v_count>0)
then
v_returncode := -1;
ELSE
v_returncode := 1;
INSERT INTO debopriyo_logincredentials (nameofuser, username, userpassword)
VALUES (p_nameofuser, p_username, p_userpassword);
END IF;
RETURN v_returncode;
END;
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Manas MohapatraRank #182 · 13.2K reputationPosted Oct 5, 2017, 1:43 AM EDT
Amit KumarRank #459 · 5.4K reputationPosted Oct 5, 2017, 2:24 AM EDT
So,
You define all parameter check it like.
if exists (select id from datatable where yourcondition )
begin
return 1
end
else
begin
// which you want Insert into table
end