Informix Error -9709: More than one distinct type of the parameter type have cast to argument type.
Cause and resolution
More than one distinct type of the parameter type have cast to argument type.
This situation occurs if more than one distinct type of the source type of the parameter has casts from the argument type. For example, assume the routine routine_name(paramtype) exists. Both paramdist1 and paramdist2 are distinct types of paramdist1. The routine is invoked as routine_name(argtype). Casts also exist from argtype to paramdist1 and argtype to paramdist2. Because distinct types inherit all the routines defined on the source types, paramdist2 and paramdist1 inherit the routine routine_name. Thus the routine resolution cannot resolve the routine, and this error results.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-9709 fires when more than one distinct type of a routine's parameter source type has a cast from the call's argument type — per the official guidance.
- Multiple distinct types over the same source type, both reachable from the argument
type via a cast, per the official guidance — the direct, only cause. For example,
routine_name(paramtype)exists;paramdist1andparamdist2are both distinct types ofparamtype; the call isroutine_name(argtype); casts exist fromargtypeto bothparamdist1andparamdist2. Since distinct types inherit routines defined on their source type, both inheritroutine_name, and resolution can't pick one.
Solutions / Resolution
- Use an explicit CAST on the argument to a specific distinct type, consistent with the official guidance's description of the ambiguity, to disambiguate which inherited routine is called.
Examples
An ambiguous call across distinct types
CREATE DISTINCT TYPE paramdist1 AS paramtype;
CREATE DISTINCT TYPE paramdist2 AS paramtype;
CREATE FUNCTION routine_name(a paramtype) RETURNING INT ...;
SELECT routine_name(some_argtype_value) FROM tab; -- -9709
Corrected
SELECT routine_name(CAST(some_argtype_value AS paramdist1)) FROM tab;
Diagnostic Checks
- Check the system catalog for distinct types sharing the same source type as the routine's parameter, and add an explicit cast to pick one.
Related Errors / Related Topics
- -9700 — "Routine (routine_name) ambiguous - more than one routine resolves to given signature." The general routine-ambiguity error this is a specific case of, arising through distinct-type inheritance specifically.
The call was ambiguous across multiple distinct types inheriting the same routine — cast the argument to a specific distinct type.