[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Return success or failure from stored procedure (login)

Posted on 2011-02-11
3
Medium Priority
?
697 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 60

Expert Comment

by:HainKurt
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 60

Accepted Solution

by:
HainKurt earned 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

649 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