Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Try It Free
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old April 15th, 2008, 01:13 PM
dwkelley86 dwkelley86 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 9 dwkelley86 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 16 m 13 sec
Reputation Power: 0
Verification Loop

The idea of the program below is to create a sql "module" (just a .sql file) that will loop and ask for a user id until the user enters the correct one. Here is the code I have thusfar:

set serveroutput on;

accept username prompt 'Enter user name here: ';
accept password prompt 'Enter password here: ';

declare
usernameCONFIRM VARCHAR(30);
passwordCONFIRM VARCHAR(30);
begin
select USERID into usernameCONFIRM from GAMEUSER where USERID = '&username';
select USERPASS into passwordCONFIRM from GAMEUSER where USERPASS = '&password';
exception
when NO_DATA_FOUND then
undefine username;
undefine password;
@login.sql;
end;

The main problem I'm seeing is that the two variables I ask for (username and password) aren't clearing out.

Reply With Quote
  #2  
Old April 15th, 2008, 07:24 PM
vpire vpire is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2005
Posts: 150 vpire User rank is Corporal (100 - 500 Reputation Level)vpire User rank is Corporal (100 - 500 Reputation Level)vpire User rank is Corporal (100 - 500 Reputation Level)vpire User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 6 h 56 m 44 sec
Reputation Power: 6
Quote:
Originally Posted by dwkelley86
The idea of the program below is to create a sql "module" (just a .sql file) that will loop and ask for a user id until the user enters the correct one. Here is the code I have thusfar:

set serveroutput on;

accept username prompt 'Enter user name here: ';
accept password prompt 'Enter password here: ';

declare
usernameCONFIRM VARCHAR(30);
passwordCONFIRM VARCHAR(30);
begin
select USERID into usernameCONFIRM from GAMEUSER where USERID = '&username';
select USERPASS into passwordCONFIRM from GAMEUSER where USERPASS = '&password';
exception
when NO_DATA_FOUND then
undefine username;
undefine password;
@login.sql;
end;

The main problem I'm seeing is that the two variables I ask for (username and password) aren't clearing out.


If your sql script is looping over and over again then you need to undefine those 2 variables at the start of the script not the end of the script.

Reply With Quote
  #3  
Old April 15th, 2008, 11:35 PM
dwkelley86 dwkelley86 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 9 dwkelley86 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 16 m 13 sec
Reputation Power: 0
Quote:
Originally Posted by vpire
If your sql script is looping over and over again then you need to undefine those 2 variables at the start of the script not the end of the script.


I did that but now I'm getting a new error:

SP2-0042: unknown command "end" - rest of line ignored.
undefine username;
*
ERROR at line 9:
ORA-06550: line 9, column 10:
PLS-00103: Encountered the symbol "USERNAME" when expecting one of the
following:
:= . ( @ % ;
ORA-06550: line 12, column 18:
PLS-00103: Encountered the symbol "ON" when expecting one of the following:
:= . ( @ % ; not null range default character

Could it have to be with how I'm calling the .sql file?

Reply With Quote
  #4  
Old April 16th, 2008, 01:58 AM
vpire vpire is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2005
Posts: 150 vpire User rank is Corporal (100 - 500 Reputation Level)vpire User rank is Corporal (100 - 500 Reputation Level)vpire User rank is Corporal (100 - 500 Reputation Level)vpire User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 6 h 56 m 44 sec
Reputation Power: 6
Quote:
Originally Posted by dwkelley86
I did that but now I'm getting a new error:

SP2-0042: unknown command "end" - rest of line ignored.
undefine username;
*
ERROR at line 9:
ORA-06550: line 9, column 10:
PLS-00103: Encountered the symbol "USERNAME" when expecting one of the
following:
:= . ( @ % ;
ORA-06550: line 12, column 18:
PLS-00103: Encountered the symbol "ON" when expecting one of the following:
:= . ( @ % ; not null range default character

Could it have to be with how I'm calling the .sql file?


You might want to try
Code:
exec sp_executesql 


But you might need to reprogram your script in order to use that and it gets kind of complicated. I think you might need to consider to write a store procedure from your code then call the store procedure.

Reply With Quote
  #5  
Old April 16th, 2008, 08:57 AM
dwkelley86 dwkelley86 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 9 dwkelley86 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 16 m 13 sec
Reputation Power: 0
I guess...
This is all so frustrating. Why does SQL have to be such a useless (in this regard) program?

Reply With Quote
  #6  
Old April 16th, 2008, 10:33 AM
LKBrwn_DBA LKBrwn_DBA is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2006
Posts: 294 LKBrwn_DBA User rank is Sergeant (500 - 2000 Reputation Level)LKBrwn_DBA User rank is Sergeant (500 - 2000 Reputation Level)LKBrwn_DBA User rank is Sergeant (500 - 2000 Reputation Level)LKBrwn_DBA User rank is Sergeant (500 - 2000 Reputation Level)LKBrwn_DBA User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 16 h 48 m 15 sec
Reputation Power: 9
Cool

Quote:
Originally Posted by dwkelley86
I guess...
This is all so frustrating. Why does SQL have to be such a useless (in this regard) program?


Maybe you actually need to study the fine Oracle manuals and tutorials on the subject and learn how to use it ... and the differences between SQL*PLus and PL/SQL.

In the script you posted you are mixing the two.

Even though I see no purpose to your script and beleive the design of the "GAMEUSER" table is flawed, this would be the correct sequence of statements for your script:

Code:
undefine username;
undefine password;

set serveroutput on;

accept username prompt 'Enter user name here: ';
accept password prompt 'Enter password here: ';

declare
  usernameCONFIRM VARCHAR(30);
  passwordCONFIRM VARCHAR(30);
begin
  select USERID, USERPASS
    into usernameCONFIRM, passwordCONFIRM
    from GAMEUSER
   where USERID = '&username'
     and USERPASS = '&password';
exception
  when NO_DATA_FOUND then 
    raise_application_error(-20001, 'User username/password not found');
end;
/



PS: The login.sql script (if present) automatically executes when you start sqlplus.
__________________

Reply With Quote
  #7  
Old April 16th, 2008, 10:46 AM
dwkelley86 dwkelley86 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 9 dwkelley86 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 16 m 13 sec
Reputation Power: 0
Quote:
Originally Posted by LKBrwn_DBA
Maybe you actually need to study the fine Oracle manuals and tutorials on the subject and learn how to use it ... and the differences between SQL*PLus and PL/SQL.

In the script you posted you are mixing the two.

Even though I see no purpose to your script and beleive the design of the "GAMEUSER" table is flawed, this would be the correct sequence of statements for your script:

Code:
undefine username;
undefine password;

set serveroutput on;

accept username prompt 'Enter user name here: ';
accept password prompt 'Enter password here: ';

declare
  usernameCONFIRM VARCHAR(30);
  passwordCONFIRM VARCHAR(30);
begin
  select USERID, USERPASS
    into usernameCONFIRM, passwordCONFIRM
    from GAMEUSER
   where USERID = '&username'
     and USERPASS = '&password';
exception
  when NO_DATA_FOUND then 
    raise_application_error(-20001, 'User username/password not found');
end;
/



PS: The login.sql script (if present) automatically executes when you start sqlplus.


...
Thank you for your help, but the insults were unecessary.
I'm just starting in this so I think you can cut me a bit of a break. There's no reason to insult someone for not knowing something.

Also, I'm t rying to loop it.. this just runs it through one time.

Reply With Quote
  #8  
Old April 16th, 2008, 11:17 AM
LKBrwn_DBA LKBrwn_DBA is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2006
Posts: 294 LKBrwn_DBA User rank is Sergeant (500 - 2000 Reputation Level)LKBrwn_DBA User rank is Sergeant (500 - 2000 Reputation Level)LKBrwn_DBA User rank is Sergeant (500 - 2000 Reputation Level)LKBrwn_DBA User rank is Sergeant (500 - 2000 Reputation Level)LKBrwn_DBA User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 16 h 48 m 15 sec
Reputation Power: 9
Thumbs down

Sorry you took my suggestion to actually study the languages you intend to use as an 'insult'.

If you had read any of the manuals or tutorials, you would have found out that there is no 'looping' functionality in SQL*PLus, only PL/SQL provides it.

Also, we could help you best if you would state the requirements you need to meet and the design of the tables you will be using.

Reply With Quote
  #9  
Old April 16th, 2008, 11:27 AM
dwkelley86 dwkelley86 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 9 dwkelley86 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 16 m 13 sec
Reputation Power: 0
<_<
I AM trying to learn about it...
I know that SQL can't do a loop, which is why the PL/SQL block exists.

the 'game user' table contains a username and password.
The purpose of this sql file is to evaluable the username and password, making sure that the correct username corresponds to the correct password.

I'm trying to set it up so that if the user fails to give hte proper login information, they have a chance to log in again, hence, the "loop".
However, if it'd be best to make a finite loop, I'm willing to do that as well.

Reply With Quote
  #10  
Old April 16th, 2008, 11:35 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,710 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 6 Days 4 h 21 m 49 sec
Reputation Power: 259
Quote:
Originally Posted by dwkelley86
I guess...
This is all so frustrating. Why does SQL have to be such a useless (in this regard) program?
Because you don't know it and it's NOT procedural, you'll have to think by sets of data (if this regard means looping)

Reply With Quote
  #11  
Old April 16th, 2008, 11:40 AM
dwkelley86 dwkelley86 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 9 dwkelley86 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 16 m 13 sec
Reputation Power: 0
Quote:
Originally Posted by pabloj
Because you don't know it and it's NOT procedural, you'll have to think by sets of data (if this regard means looping)


That doesn't help me with the problem I'm' having...

Reply With Quote
  #12  
Old April 16th, 2008, 11:47 AM
LKBrwn_DBA LKBrwn_DBA is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2006
Posts: 294 LKBrwn_DBA User rank is Sergeant (500 - 2000 Reputation Level)LKBrwn_DBA User rank is Sergeant (500 - 2000 Reputation Level)LKBrwn_DBA User rank is Sergeant (500 - 2000 Reputation Level)LKBrwn_DBA User rank is Sergeant (500 - 2000 Reputation Level)LKBrwn_DBA User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 16 h 48 m 15 sec
Reputation Power: 9
Exclamation

Quote:
Originally Posted by dwkelley86
<_<
I AM trying to learn about it...
I know that SQL can't do a loop, which is why the PL/SQL block exists.

the 'game user' table contains a username and password.
The purpose of this sql file is to evaluable the username and password, making sure that the correct username corresponds to the correct password.

I'm trying to set it up so that if the user fails to give hte proper login information, they have a chance to log in again, hence, the "loop".
However, if it'd be best to make a finite loop, I'm willing to do that as well.


The loop you seek would have to be at the SQL*Plus level surrouding the PL/SQL block and therefore cannot be implemented due to the fact stated: there is no 'looping' functionality in SQL*PLus.

Also, in order to execute any script and/or procedure, you already need to be login to the database with a valid username/password.


Reply With Quote
  #13  
Old April 16th, 2008, 11:59 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,710 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 6 Days 4 h 21 m 49 sec
Reputation Power: 259
note that what you're trying to do is usually done at application level (written with any language, php, java ...) which gets a username and password, verifies them against the database and either goes on with the app or sends the user back to the login form, no looping, you are mis describing the desired behavior when you talk about looping.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Verification Loop


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump