Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

retrive rows affected number

Status
Not open for further replies.

dannG

Programmer
Jan 9, 2003
26
0
0
RO
Hello!
I'm new in MYSQL.
I'm trying to migrate some MS Sql Stored Procedures in MySql. Here is the MSSQL stored procedure.
Code:
CREATE PROCEDURE CB_UserLogin
(
    @User      nvarchar(50),
    @Pass   nvarchar(50),
    @ID_Util int OUTPUT
)
AS

SELECT 
    @ID_Util = fID_Util
    
FROM 
    tblUtiliz
    
WHERE 
    fUtilizator = @User
  AND 
    fParola = @Pass

IF @@Rowcount < 1 
SELECT 
    @ID_Util = 0

My problem is the in translating the last part of this SP. I need the number of affectes rows by the first part of SP.

The following code is not accepted as a correct one.
Any help will be appreciated! Thx

Code:
CREATE PROCEDURE CB_UserLogin
(
    VUser      varchar(50),
    VPass   varchar(50),
    OUT VID_Util int 
)
begin

SELECT 
    @ID_Util = fID_Util
    
FROM 
    tblUtiliz
    
WHERE 
    fUtilizator = @User
  AND 
    fParola = @Pass;

IF Row_count() < 1 then @ID_Util = 0
end if;
end;
 
Hi
I think I solved the problem. Maybe someone need it...

Code:
CREATE PROCEDURE CB_UserLogin
(
    VUser      varchar(50),
    VPass   varchar(50),
    OUT VID_Util int 
)
begin

SELECT 
    fID_Util
    
FROM 
    tblUtiliz
    
WHERE 
    fUtilizator = @User
  AND 
    fParola = @Pass;

IF Row_count() < 1 then 
 SET VID_Util = 0;
Else
 Set VID_Util=fID_Util;
end if;
end;

cheers!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top