Informix Error -657
-657 Cannot create a procedure within a procedure.
You cannot have a CREATE PROCEDURE statement within a CREATE PROCEDURE statement.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-657 fires when a CREATE PROCEDURE (or CREATE FUNCTION) statement appears inside the body of
another CREATE PROCEDURE statement — per the official guidance, SPL routines can't be nested
this way.
- A
CREATE PROCEDURE/CREATE FUNCTIONstatement written inside another routine's body, per the official guidance — the direct, only cause. - A misunderstanding of SPL routine scoping, expecting nested routine definitions to work the way local function definitions do in some general-purpose programming languages.
Solutions / Resolution
- Define the two routines as separate, top-level
CREATE PROCEDURE/CREATE FUNCTIONstatements, rather than nesting one inside the other. - Have the outer routine call the other routine by name, using
EXECUTE PROCEDURE/EXECUTE FUNCTIONor a direct function call, once both are defined separately.
Examples
The disallowed attempt
CREATE PROCEDURE outer_proc()
CREATE PROCEDURE inner_proc()
...
END PROCEDURE;
-- -657: CREATE PROCEDURE can't appear inside another CREATE PROCEDURE
END PROCEDURE;
Corrected — two separate top-level routines
CREATE PROCEDURE inner_proc()
...
END PROCEDURE;
CREATE PROCEDURE outer_proc()
EXECUTE PROCEDURE inner_proc();
END PROCEDURE;
Diagnostic Checks
- Scan the routine body for a
CREATE PROCEDURE/CREATE FUNCTIONstatement, and pull it out to a separate, top-level definition.
Related Errors / Related Topics
No closely related error codes are cross-referenced for -657 in this set yet.
SPL routines can't be nested — define both routines separately at the top level, and have one call the other by name.