USP_DATAFORMTEMPLATE_VIEW_CURRENCYEXCHANGERATE_FIRSTAVAILABLE

The load procedure used by the view dataform template "First Available Currency Exchange Rate"

Parameters

Parameter Parameter Type Mode Description
@ID nvarchar(84) IN The input ID parameter used to load the fields defined on the form.
@DATALOADED bit INOUT Output parameter indicating whether or not data was actually loaded.
@EXCHANGERATEID uniqueidentifier INOUT Exchange rate ID

Definition

Copy


CREATE procedure dbo.USP_DATAFORMTEMPLATE_VIEW_CURRENCYEXCHANGERATE_FIRSTAVAILABLE
(
    @ID nvarchar(84),
    @DATALOADED bit = 0 output,
    @EXCHANGERATEID uniqueidentifier = null output
)
as
    set nocount on;

    declare @INDEX as integer;
  declare @INDEX1 as integer;
  declare @FROMCURRENCYID nvarchar(36);
  declare @TOCURRENCYID nvarchar(36);
  declare @ASOFDATE nvarchar(10);

  set @INDEX = CHARINDEX(';', @ID);
  set @INDEX1 = CHARINDEX(';', @ID, @INDEX + 1);

  set @FROMCURRENCYID = SUBSTRING(@ID, 0, @INDEX);
  set @TOCURRENCYID = SUBSTRING(@ID, @INDEX + 1, @INDEX1 - (@INDEX + 1));
  set @ASOFDATE = SUBSTRING(@ID, @INDEX1 + 1, LEN(@ID) - @INDEX1);

  declare @temp table(VALUE uniqueidentifier, LABEL nvarchar(100))
  insert into @temp
  exec USP_SIMPLEDATALIST_CURRENCYEXCHANGERATES @FROMCURRENCYID, @TOCURRENCYID, 1, @ASOFDATE;

    -- be sure to set this, in case the select returns no rows

    set @DATALOADED = 1;

    select TOP 1 @EXCHANGERATEID = VALUE from @temp

    return 0;