Subject | MS-Sql outparamter, is this the way to do it? |
---|---|
Author | jclichthouse |
Post date | 2011-07-03T17:10:54Z |
Hi there,
I have converted this MS-Sql sp to firebird. Can someone please tel me if i did it the right way or did i misunderstand something.
Thanks
Edwin
[MS-Sql]
CREATE PROCEDURE LAND_I
(
@LANDCODE NVARCHAR(5)
, @LANDNAAM NVARCHAR(50)
, @RETURNVALUE INT OUTPUT
)
AS
BEGIN
DECLARE @VALUE NVARCHAR(5);
SET @VALUE = (SELECT COUNTRYCODE FROM TBLCOUNTRYS WHERE COUNTRYCODE = @LANDCODE AND COUNTRYNAME = @LANDNAAM)
IF @VALUE IS NULL
BEGIN
INSERT INTO TBLLANDEN(COUNTRYCODE, COUNTRYNAME ) VALUES ( @LANDCODE, @LANDNAAM)
IF @@ROWCOUNT > 0
SET @RETURNVALUE = 999
ELSE
SET @RETURNVALUE = 997
END
ELSE
SET @RETURNVALUE = 998
END
[/MS-Sql]
after converting i get this
[Firebird]
SET TERM ^ ;
CREATE PROCEDURE Country_I
(
LandCode varchar(5)
, landNaam varchar(50)
)
RETURNS
( ReturnValue int )
AS
DECLARE VARIABLE checkvalue varchar(5);
BEGIN
returnValue = 0;
checkvalue = (SELECT countrycode FROM TBLCOUNTRYS WHERE countrycode = :LandCode AND countryname = :LandNaam);
if ( checkvalue is NULL ) THEN
BEGIN
INSERT INTO TBLCOUNTRYS (countrycode, countryname)
VALUES (:LandCode, :landNaam);
if ( ROW_COUNT > 0 ) THEN
BEGIN
returnValue = 999;
END
ELSE
BEGIN
returnValue = 997;
END
END
ELSE
returnValue = 998;
END^
SET TERM ; ^
[/Firebird]
I have converted this MS-Sql sp to firebird. Can someone please tel me if i did it the right way or did i misunderstand something.
Thanks
Edwin
[MS-Sql]
CREATE PROCEDURE LAND_I
(
@LANDCODE NVARCHAR(5)
, @LANDNAAM NVARCHAR(50)
, @RETURNVALUE INT OUTPUT
)
AS
BEGIN
DECLARE @VALUE NVARCHAR(5);
SET @VALUE = (SELECT COUNTRYCODE FROM TBLCOUNTRYS WHERE COUNTRYCODE = @LANDCODE AND COUNTRYNAME = @LANDNAAM)
IF @VALUE IS NULL
BEGIN
INSERT INTO TBLLANDEN(COUNTRYCODE, COUNTRYNAME ) VALUES ( @LANDCODE, @LANDNAAM)
IF @@ROWCOUNT > 0
SET @RETURNVALUE = 999
ELSE
SET @RETURNVALUE = 997
END
ELSE
SET @RETURNVALUE = 998
END
[/MS-Sql]
after converting i get this
[Firebird]
SET TERM ^ ;
CREATE PROCEDURE Country_I
(
LandCode varchar(5)
, landNaam varchar(50)
)
RETURNS
( ReturnValue int )
AS
DECLARE VARIABLE checkvalue varchar(5);
BEGIN
returnValue = 0;
checkvalue = (SELECT countrycode FROM TBLCOUNTRYS WHERE countrycode = :LandCode AND countryname = :LandNaam);
if ( checkvalue is NULL ) THEN
BEGIN
INSERT INTO TBLCOUNTRYS (countrycode, countryname)
VALUES (:LandCode, :landNaam);
if ( ROW_COUNT > 0 ) THEN
BEGIN
returnValue = 999;
END
ELSE
BEGIN
returnValue = 997;
END
END
ELSE
returnValue = 998;
END^
SET TERM ; ^
[/Firebird]