USP_DATAFORMTEMPLATE_ADD_CURRENCYEXCHANGERATEBATCHCOMMIT

The save procedure used by the add dataform template "Currency Exchange Rate Batch Row Commit Add Form".

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier INOUT The output parameter indicating the ID of the record added.
@VALIDATEONLY bit IN Validate only
@CHANGEAGENTID uniqueidentifier IN Input parameter indicating the ID of the change agent invoking the procedure.
@FROMCURRENCYID uniqueidentifier IN From currency
@TOCURRENCYID uniqueidentifier IN To currency
@RATE decimal(20, 8) IN Rate
@ASOFDATE datetime IN As of date
@ASOFTIME time IN As of time
@TYPECODE tinyint IN Type
@SOURCECODEID uniqueidentifier IN Source
@TIMEZONEENTRYID uniqueidentifier IN Time zone

Definition

Copy

CREATE procedure dbo.USP_DATAFORMTEMPLATE_ADD_CURRENCYEXCHANGERATEBATCHCOMMIT
(
  @ID uniqueidentifier = null output,
  @VALIDATEONLY bit = 0,
  @CHANGEAGENTID uniqueidentifier = null,
  @FROMCURRENCYID uniqueidentifier,
  @TOCURRENCYID uniqueidentifier,
  @RATE decimal(20,8) = 0,
  @ASOFDATE datetime,
  @ASOFTIME time(0),
  @TYPECODE tinyint = 0,
  @SOURCECODEID uniqueidentifier = null,
  @TIMEZONEENTRYID uniqueidentifier = null
)
as begin
  set nocount on;

  if @ID is null
    set @ID = newid();

  if @CHANGEAGENTID is null
    exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output;

  declare @CURRENTDATE datetime;
  set @CURRENTDATE = getdate();

  begin try

    if @TIMEZONEENTRYID is null
      set @TIMEZONEENTRYID = dbo.UFN_TIMEZONEENTRY_GETSYSTEMDEFAULT();

    declare @ASOFDATETIME datetime = @ASOFDATE + CAST(@ASOFTIME as datetime);
    declare @UTCOFFSET integer = dbo.UFN_TIMEZONEENTRY_GETTIMEZONEOFFSETFROMUTC(@TIMEZONEENTRYID, @ASOFDATETIME, 0);
    declare @ASOFDATETIMEOFFSET datetimeoffset = TODATETIMEOFFSET(@ASOFDATETIME, @UTCOFFSET);
    declare @EXPIRATIONDATETIMEOFFSET datetimeoffset = dbo.UFN_CURRENCY_GETEXPIRATIONDATE(@TYPECODE,@ASOFDATE,@TIMEZONEENTRYID);


    --Insert the new exchange rate record.
    exec dbo.USP_CURRENCYEXCHANGERATE_ADD
      @ID,
      @FROMCURRENCYID,
      @TOCURRENCYID,
      @RATE,
      @ASOFDATETIMEOFFSET,
      @TYPECODE,
      @SOURCECODEID,
      @TIMEZONEENTRYID,
      @EXPIRATIONDATETIMEOFFSET,
      @CHANGEAGENTID,
      @CURRENTDATE;

  end try

  begin catch
    exec dbo.USP_RAISE_ERROR;
    return 1;
  end catch

  return 0;
end