If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Informix > stored procedure "686 Function has returned more than one row."

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-11-08, 10:57
kumarshetty kumarshetty is offline
Registered User
 
Join Date: Jul 2008
Posts: 3
stored procedure "686 Function has returned more than one row."

Hi All,

this is the sample code of my issue.

CREATE PROCEDURE A(int,int)
RETURNING int,int,int,int,int,int ;
-
-- here I define variables
-
FOREACH cur_a FOR
SELECT
-
-
FROM
-
-
INTO
-
-
WHERE
-
-
CALL PROCEDURE B(int,int)
RETURNING int,int,int ;
-
-
-- here iam returning the values of procedure B also
RETURN a,b,c,x,y,z WITH RESUME ;
END FOREACH
END PROCEDURE ;

=======================

CREATE PROCEDURE B(int,int)
RETURNING int,int,int ;
-
-- here i define variables
-
FOREACH cur_b FOR
SELECT
-
-
INTO
-
-
WHERE
-
-
RETURN x,y,z WITH RESUME ;
END FOREACH
END PROCEDURE ;

====================================

I have a requirement in which I call procedure A which returns multiple rows and for each row I have to call a procedure B which in turn returns multiple rows.

I dont get any syntax error in any of procedure.

When I call the procedure B from procedure A, I get below error message.

"686: Function B has returned more than one row."

If I call the procedure B with sample values, it executes as it is expected.

It seems I have to change my code in procedure A to handle the return value of procedure B or might be i have to change logic of procedure A.

I am new to informix and please help me in this issue.

thanks,
-- kumar
Reply With Quote
  #2 (permalink)  
Old 07-14-08, 13:10
ceinma ceinma is offline
Registered User
 
Join Date: Apr 2007
Location: Jundiai / SP - Brasil
Posts: 311
What version of IDS you are using?

Always you use the "RETURN...WITH RESUME", this means your procedure will behave like a sql return. So, this way you can't return multiple lines inside only one variable!

You need to change the call of procedureB .

If you are using IDS 11.x you can access the procedure like this example :
Code:
create table teste(
  cod integer, desc char(10), tipo char(1)
  );
insert into teste values (1,'um',"a");
insert into teste values (2,'dois',"a");
insert into teste values (3,'tres',"b");
insert into teste values (4,'quatro',"b");
insert into teste values (5,'cinco',"c");

create procedure procb(pTipo char(1)) returning int,char(10);
  define valA integer;
  define valB char(10);
  foreach cursorA for
    select cod, upper(desc) into valA, valB from teste
    where tipo = pTipo
    return valA,valB with resume ;
  end foreach
  ;
end procedure
;
create procedure procA() returning int,char(10);
  define vTipo char(1);
  define valA  int;
  define valB  char(10);
  foreach cursorA for
    select unique tipo into vTipo from teste
    order by 1 desc
    foreach cursorB for
      select col1,col2 into valA, valB from table(procb(vTipo)) (col1,col2)
      return valA, valB with resume
      ;
    end foreach
    ;
  end foreach
  ;
end procedure
;
select * from table(proca()) myVirtual_table (colA,colB);
I am not sure, but with version 10 , maybe this works too.
__________________
________________________________________
César Inacio Martins
Jundiai / SP - Brasil
http://www.imartins.com.br/informix - em Português
http://www.imartins.com.br/informix - English (translated by Google).
________________________________________

Last edited by ceinma; 07-14-08 at 13:20.
Reply With Quote
  #3 (permalink)  
Old 07-21-08, 21:38
kumarshetty kumarshetty is offline
Registered User
 
Join Date: Jul 2008
Posts: 3
Thanks, Ceinma....it has resolved my issue.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On