Subject Re: nested procedures
Author kisa933
> If your code is correct, are you sure that PROC_A uses an input
param whose
> type can handle all the range of the passed argument? If A and D
have
> similar logic, it's possible that A's input param is a smallint but
D is
> passing an integer... good cause for an arithmetic exception.
>
> C.
> --
> Claudio Valderrama C. - http://www.cvalde.com -
http://www.firebirdSql.org
> Independent developer
> Owner of the Interbase® WebRing

Sorry, I was not exact in writing down the problem, because I didn'n
want anybody be bored with my code.
The original code is a bit long so I try to sum a shorter vesion of
it including the involved procedures.


CREATE PROCEDURE SPR_GET_FBESZAMOLOOSSZEG(
AZON INTEGER,
BESZAMOLO SMALLINT,
OSZLOP SMALLINT)
RETURNS (
OSSZEG NUMERIC(18,2))
AS
declare variable DEFTIPUS SMALLINT;
declare variable FORMULA CHAR(128);
declare variable OSZLOPID SMALLINT;
declare variable INTKEZD DATE;
declare variable INTVEG DATE;
BEGIN
osszeg = 0;
SELECT deftipus
FROM fbeszamolo
WHERE fbeszamolo.azon = :azon
INTO :deftipus;
SELECT OSZLOPID, INTKEZD, INTVEG
FROM TOSZLOP
WHERE (AZON = :beszamolo) AND
(OSZLOP = :oszlop)
INTO :oszlopid, :intkezd, :intveg;
SELECT FORMULA
FROM foszlopdef
WHERE (AZON = :azon) AND
(BESZAMOLO = :beszamolo) AND
(OSZLOPID = :oszlopid) AND
(USED = 0)
INTO :formula;
if (:formula is NULL) then
formula = '0';
SELECT EXPVALUE
FROM spr_process_expression(:beszamolo, :oszlop, :formula)
INTO :osszeg;
SUSPEND;

END

CREATE PROCEDURE SPR_PROCESS_EXPRESSION(
BESZAMOLO SMALLINT,
OSZLOP SMALLINT,
EXPRESSION CHAR(128))
RETURNS (
EXPVALUE NUMERIC(18,2))
AS
declare variable Tag CHAR(128);
BEGIN
ExpValue = 0;
Tag = '';

...

select :ExpValue + Tagvalue
from spr_process_expressiontag(:beszamolo, :oszlop, :tag)
into :ExpValue;
SUSPEND;
END


CREATE PROCEDURE SPR_PROCESS_EXPRESSIONTAG(
BESZAMOLO SMALLINT,
OSZLOP SMALLINT,
EXPRESSIONTAG CHAR(128))
RETURNS (
TAGVALUE NUMERIC(18,2))
AS
declare variable Tag CHAR(128);
BEGIN
TagValue = 0;
Tag = '';

...

SELECT :TagValue * OpValue
FROM spr_process_operandus(:beszamolo, :oszlop, :tag)
INTO :TagValue;
SUSPEND;
END


CREATE PROCEDURE SPR_PROCESS_OPERANDUS(
BESZAMOLO SMALLINT,
OSZLOP SMALLINT,
OPERANDUS CHAR(128))
RETURNS (
OPVALUE NUMERIC(18,2))
AS
declare variable Azon INTEGER;
BEGIN
OpValue = 0;

...

if (Beszamolo is not NULL) then
SELECT osszeg
FROM spr_get_fbeszamoloosszeg(:Azon, :Beszamolo, :Oszlop)
INTO :OpValue;
else
OpValue = CAST(substr(Operandus, 1, 15) AS NUMERIC(15, 2));
SUSPEND;
END

I think that params and args are exactly defined but char type
arguments are handled with UDFs in the rest of the code. Would it
cause that behavior?

Kiss S