I am trying to make a simple function that reads a table from an ORACLE database and returns a sequence number. I would either like to return it directly or store the value inside of @cwpSeq and return that to the calling program.
Right now I am getting error:
RETURN statements in scalar valued functions must include an argument.
Can anyone assist me.
create function dbo.get_cwpSeq_from_oracle(@COIL nvarchar(100) )
returns int as
begin
DECLARE @cwpSeq int, @SQL nvarchar(1000);
set @SQL = N'select * from openquery(DEV, 'select cwp_seq from apps.custom_wip_pieces where lot_number = ''' + @COIL + '')';
return execute sp_executesql @SQL;
end;