Subject conversion of sql server stored proc
Author ptpics99
Hi,

I'm running FB 2.5 beta 2 and I'm porting a sql server db over to FB.

I'm having trouble converting the following stored proc which essentially selects a row from a table of values (sequences in a single table) and returns the next value after incrementing it by 1.

e.g
SOME_ID 567
THIS_VALUE 10
THAT_VALUE 21

Executing usp_GetNewValue('SOME_ID') would increment that row in the table to 568 and return 568.

Could anyone convert this for me please?

create procedure usp_GetNewValue
@SeqName nvarchar(30)
as
begin
declare @NewSeqVal int
set NOCOUNT ON
update AUTONO
set @NewSeqVal = ITEMVALUE = ITEMVALUE + 1
where ITEM = @SeqName

if @@rowcount = 0 begin
return -1
end

return @NewSeqVal
end

Regards, Paul.