Solved

Return success or failure from stored procedure (login)

Posted on 2011-02-11
3
693 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 54

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 54

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

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 …
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

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