Solved

Return success or failure from stored procedure (login)

Posted on 2011-02-11
3
692 Views
Last Modified: 2012-05-11
I have a stored procedure .... basically I want it to return a success (somehow)  if the  table called in the stored procedure has a username and password combo and not sucesful if it does not.

How could I bet do this?
0
Comment
Question by:vbnetcoder
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 51

Expert Comment

by:Huseyin KAHRAMAN
ID: 34875373
use function

create function login(parameters here) as int
begin
 ...
 if (....) return 0 else return 1; ' 0:success, 1 failed
end;
0
 
LVL 51

Accepted Solution

by:
Huseyin KAHRAMAN earned 500 total points
ID: 34875405
actually syntax is

create function login(@p1 integer, @p2 varchar) returns integer as
begin
  declare @result integer =0;
  select @result = sign(count(1)) from users where userid=@p1 and password=@p2;
  return @result; -- 0 : failed, no such user, 1: success there is a user with that password  
end;
0
 

Author Closing Comment

by:vbnetcoder
ID: 34875469
TY
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question