Hi All,

I am needing some help using SYBASE 11 creating a stored procedure. I have a working one in SQL 2005 but having no luck getting one to work in SYBASE. Really need help grasping the different methods.

SQL 2005
Code:
CREATE PROCEDURE [dbo].[get_part_id] @outvar char(9)  output
AS 
declare @part_id as decimal


begin transaction
TABLOCKX
select @part_id=fnpartid
from participant_id

if @part_id is null
begin
      set @part_id = 1
      insert participant_id values( @part_id)
end
else
begin
      update participant_id set fnpartid = @part_id + 1
end
select @part_id
set @outvar = @part_id
commit transaction
My Attempt on SYBASE
Code:
CREATE procedure dbo.get_partid @outvar INT OUTPUT 
AS 

DECLARE @part_id INT

BEGIN TRAN
        DECLARE partid_crs cursor for

    SELECT @part_id=fnPartID FROM participant_id  
    
        IF @part_id IS NULL 
    begin
    
        OPEN CURSOR partid_crs
        SET @part_id=1 
        INSERT participant_id VALUES(@part_id) 
    end
        ELSE
    begin
        UPDATE participant_id SET fnPartID = @part_id + 1 
    end


SELECT @part_id
SET @outvar = @part_id
COMMIT TRAN
Thanks in advance