Solved

Return success or failure from stored procedure (login)

Posted on 2011-02-11
3
688 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
  • 2
3 Comments
 
LVL 51

Expert Comment

by:HainKurt
Comment Utility
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:
HainKurt earned 500 total points
Comment Utility
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
Comment Utility
TY
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

728 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now