ここでは、移行済み DB2 データベースが、数学の組み込み関数である atanh (これは、SQL Server データベースではサポートされていません) を使用するシナリオを例として示します。このシナリオでは、Microsoft SQL Server Management Studio を使用して SQL Server データベースのデフォルト dbo スキーマに関数を作成し、HCOSS を使用して DB2 関数を新規作成した SQL Server のユーザ定義関数にマップします。
create function atanh (@in float) returns float begin return log((1 + @in) / (1 - @in)) / 2 end go
declare @x float = 0.75 select dbo.atanh(@x)
$set sql(targetdb=mssqlserver db=HCODemo dialect=mainframe, init)
identification division.
program-id. Program1.
environment division.
configuration section.
data division.
working-storage section.
exec sql include sqlca end-exec.
01 mfsqlmessagetext pic x(200).
01 x comp-2.
01 atanh comp-2.
01 digits comp-2
procedure division.
move 0.25 to x
exec sql
select atanh(:x)
into :atanh
end-exec
display atanh
goback.