result from procedure

  • hi,

    I need a solution to this problem, i have a procedure that i want to return a value and i dont know the select statement to use.This is a sample of the statement below

    CREATE    PROCEDURE getuser

    @person_id int out,

    @usn varchar (40),

    @pass varchar (15)

    AS

    if  exists (SELECT Email,Pass FROM dbo.PersonalDetails WHERE Email = @usn AND Pass= @pass)

    begin

    select person_id = @person_id from personaldetails where email = @usn

    end

    GO

    i want to extract person_id into the variable @person_id

  • Hi,

      Use Return statement in the stored proc instead of "select person_id"

     then

    Declare @outvariable int

    Exec @outvariable=getuser(<the required parameters&gt

    select ourresult=@outvariable

    I trust this clears u r requirement

    for eg:

    create proc add1(

    @invalue

    varchar(10)

    )

    as

    begin

    declare

    @outvalue int

    set

    @outvalue=@invalue+2

    Return

    @outvalue

    end

    -- For testing the above proc

    declare @in int

    Exec @in= add1 0

    select

    ou= @in

     

     

  • i got ur message but it not exactly helping me out

    what i wanted to do is like this ...here is a structure of the table how it loooks

    Person_id      email        username

    1           enny@yahoo.com   enny

    2          dave@yahoo.com    dave

     

    the procedure should return person id

    thanks

  • This should do it :

    select @person_id = person_id from personaldetails where email = @usn

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply