Conditional concatenation in DB-mapping

In the DB-mapping I would like to concatenate a text value with a specific fixed text, depending on the value of another text field. Something like this (pseudo-code!):

'Relatienummer': text = match $ .'Relatiesoort' equals "D"
	| true = concat ( "16" , to-text $ .'Relatienummer' )
	| false = match $ .'Relatiesoort' equals "C"
		| true = concat ( "25" , to-text $ .'Relatienummer' )
		| false = to-text $ .'Relatienummer'

But it seems that match doesn’t work with type text. How to handle this?

The probleem here is that match is part of the state mapping, so it can only be used to assign a stategroup.
With the exception of switch on enum, the RDB only supports conditional expressions when assigning a stategroup.

Where and how should I then concatenate the required text to the DB-text field, depending on the other DB-text field?

The match must be a part of the expression setting the stategroup, but multiple branches in the state mapping can result in the same state:

'State Group': stategroup = match ...
  | true = 'State' (
    'Value': text = concat ( "16", ... )
  )
  | false = 'State' (
    'Value': text = concat ( "25", ... )
 )

Alternatively 'Relatiesort' can be changed from a text to an enum in the table definition (database.alan). This requires that 'Relatiesort' has a predefined set of possible values.
This allows you to switch on the enum in a text expression.

'Value': text = switch $ ?'Enum DB Field' (
  |'Enum Value A' = concat ( "16", ... )
  |'Enum Value B' = concat ( "25", ... )
  ...
)