Subject | MULTIPLE ROWS IN SINGLETON SELECT in SP |
---|---|
Author | Tanz Anthrox |
Post date | 2004-01-21T10:27:43Z |
The Stored Procedure shown below is prepared for Bill Of Material.
But, the marked line has Multiple Rows sometimes and gives an error.
How can I solve this problem? Any suggestion
CREATE PROCEDURE PR_BOMVIEW (
BOM_MALZEMEKODU VARCHAR (40))
RETURNS (
CHILD VARCHAR (40),
CHILDNAME VARCHAR (255))
AS
DECLARE VARIABLE HAS_CHILDREN SMALLINT;
BEGIN
FOR
SELECT B.CHILD,M.MALZEMEACIKLAMA FROM BOM B
JOIN MALZEME M
ON B.CHILD = M.MALZEMEKODU
WHERE B.PARENT = :BOM_MALZEMEKODU
INTO :CHILD,:CHILDNAME
DO
BEGIN
SELECT COUNT(*) FROM BOM b2 WHERE b2.PARENT=:CHILD INTO :HAS_CHILDREN;
IF (HAS_CHILDREN<>0) THEN
BEGIN
select child,childname from PR_BOMVIEW(:CHILD) INTO :CHILD,:CHILDNAME; /* THIS LINE CAUSES MULTIPLE ROWS IN SINGLETON SELECT */
END
SUSPEND;
END
END
[Non-text portions of this message have been removed]
But, the marked line has Multiple Rows sometimes and gives an error.
How can I solve this problem? Any suggestion
CREATE PROCEDURE PR_BOMVIEW (
BOM_MALZEMEKODU VARCHAR (40))
RETURNS (
CHILD VARCHAR (40),
CHILDNAME VARCHAR (255))
AS
DECLARE VARIABLE HAS_CHILDREN SMALLINT;
BEGIN
FOR
SELECT B.CHILD,M.MALZEMEACIKLAMA FROM BOM B
JOIN MALZEME M
ON B.CHILD = M.MALZEMEKODU
WHERE B.PARENT = :BOM_MALZEMEKODU
INTO :CHILD,:CHILDNAME
DO
BEGIN
SELECT COUNT(*) FROM BOM b2 WHERE b2.PARENT=:CHILD INTO :HAS_CHILDREN;
IF (HAS_CHILDREN<>0) THEN
BEGIN
select child,childname from PR_BOMVIEW(:CHILD) INTO :CHILD,:CHILDNAME; /* THIS LINE CAUSES MULTIPLE ROWS IN SINGLETON SELECT */
END
SUSPEND;
END
END
[Non-text portions of this message have been removed]