Recommendations for naming transform groups
This topic describes the recommendations for naming transform groups.
Transform group names are unqualified identifiers; that is, they are not associated with any specific schema. Unless you are writing transforms to handle subtype parameters, you should not assign a different transform group name for every structured type. Because you might need to use several different, unrelated types in the same program or in the same SQL statement, you should name your transform groups according to the tasks performed by the transform functions.
The names of your transform groups should generally reflect the
function they perform without relying on type names or in any way
reflecting the logic of the transform functions, which will likely
be very different across the different types. For example, you could
use the name func_group
or object_functions
for
any group in which your TO and FROM SQL function transforms are defined.
You could use the name client_group
or program_group
for
a group that contains TO and FROM SQL client transforms.
In the following example, the Address_t
and Polygon
types
use very different transforms, but they use the same function group
names
CREATE TRANSFORM FOR Address_t
func_group (TO SQL WITH FUNCTION functoaddress,
FROM SQL WITH FUNCTION addresstofunc );
CREATE TRANSFORM FOR Polygon
func_group (TO SQL WITH FUNCTION functopolygon,
FROM SQL WITH FUNCTION polygontofunc);
Once you set the transform group to func_group
in the appropriate situation,
Db2® invokes the
correct transform function whenever you bind in or bind out an address or polygon.
When you define an external function or method and you do not specify a transform group name, Db2 attempts to use the name DB2_FUNCTION, and assumes that that group name was specified for the given structured type. If you do not specify a group name when you precompile a client program that references a given structured type, Db2 attempts to use a group name called DB2_PROGRAM, and again assumes that the group name was defined for that type.
This default behavior is convenient in some cases, but in a more complex database schema, you might want a slightly more extensive convention for transform group names. For example, it might help you to use different group names for different languages to which you might bind out the type.