Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Oracle PL/SQL Stored Procedure using IF statement

403084Dec 24 2003 — edited Dec 29 2003
Hi,

I'm having trouble using a PL/SQL stored procedure that takes two input parameters and I want to use an IF statement.

This is what I have so far (doesn't work)

CREATE OR REPLACE PROCEDURE CheckPassword

(txtusername in varchar2, txtpassword in varchar2)

AS

BEGIN

IF EXISTS
(
SELECT User_ID FROM UserList WHERE User_Username =
txtusername AND User_Password = txtpassword;
)
THEN
RETURN 0;

END IF;

IF EXISTS
(
SELECT User_ID FROM UserList WHERE User_Username = txtusername
)

THEN

RETURN 1;
ELSE
RETURN 2;

END IF;

END;

Here's my oracle table that I'm using:

SQL> select * from userlist;

USER_ID USER_USERNAME USER_PASSWORD
---------- -------------------- -------------------
1 Jones clouds
2 Elena soccer

I want to replace the 'EXISTS' with an If condition such as If (txtusername == "Jones") THEN do the select statement..

how do I go about creating this condition in an oracle PL/SQL stored procedure?

I'm also trying to locate some examples.

Any suggestions would be appreciated.

This stored procedure will authenticate the user that logs in to an application.

The parameters above will be assigned the values from the textboxes of the Login page.

oracleSelectCommand1.Parameters[ "txtusername" ].Value = txtUsername.Text;

oracleSelectCommand1.Parameters[ "txtpassword" ].Value = txtPassword.Text;

Thanks.

bebop




Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 26 2004
Added on Dec 24 2003
1 comment
15,545 views