Consultor Eletrônico



Kbase P117515: Error (3241) invoking an external procedure with a user defined function.
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   9/15/2009
Status: Verified

SYMPTOM(s):

Error (3241) invoking an external procedure with a user defined function.

Parameter buffer for <buffer> in <procedure> not matched by caller. (3241)

Parameter buffer for B_File in fnTest functest.p not matched by caller. (3241)

Executing the following code:
/* runtest.p */
CREATE ALIAS "DICTDB" FOR DATABASE sports.
COMPILE functest.p SAVE.
RUN functest.p.
DELETE ALIAS DICTDB.
CREATE ALIAS "DICTDB" FOR DATABASE sports2000.
RUN functest.p.
Where functest.p:
/* functest.p */
FUNCTION fnTest RETURNS LOGICAL
(BUFFER B_File FOR DICTDB._File):
RETURN TRUE.
END FUNCTION.
DEFINE BUFFER B_File FOR DICTDB._File.
FIND FIRST B_File NO-LOCK.
RUN ipTest (BUFFER B_File).
MESSAGE "Procedure returns:" RETURN-VALUE
VIEW-AS ALERT-BOX INFO BUTTONS OK.
MESSAGE "Function returns:" fnTest(BUFFER B_File)
VIEW-AS ALERT-BOX INFO BUTTONS OK.
PROCEDURE ipTest:
DEFINE PARAMETER BUFFER B_File FOR DICTDB._File.
RETURN "Done".
END PROCEDURE.

FACT(s) (Environment):

All Supported Operating Systems
Progress 9.x
OpenEdge 10.x

CAUSE:

This is expected behavior as the compilation of functest.p in the statement:
COMPILE functest.p SAVE.
stores the name of the logical database in addition to the alias because it is defined with a buffer parameter.

FIX:

Recompile the procedure functest.p after changing the creating the alias for the second database:
/* runtest.p */
CREATE ALIAS "DICTDB" FOR DATABASE sports.
COMPILE functest.p SAVE.
RUN functest.p.
DELETE ALIAS DICTDB.
CREATE ALIAS "DICTDB" FOR DATABASE sports2000.
COMPILE functest.p SAVE.
RUN functest.p.
Or do not pass the buffer as a parameter to the user defined function. But simply use the buffer inside the function as needed. For example:
/* functest.p */
DEFINE BUFFER B_File FOR DICTDB._File.
FIND FIRST B_File NO-LOCK.
FUNCTION fnTest RETURNS CHARACTER:
RETURN B_File._File-Name.
END FUNCTION.

RUN ipTest (BUFFER B_File).
MESSAGE "Procedure returns:" RETURN-VALUE
VIEW-AS ALERT-BOX INFO BUTTONS OK.
MESSAGE "Function returns:" fnTest()
VIEW-AS ALERT-BOX INFO BUTTONS OK.
PROCEDURE ipTest:
DEFINE PARAMETER BUFFER B_File FOR DICTDB._File.
RETURN "Done".
END PROCEDURE.