Procedure does not return the full column

Asked

Viewed 47 times

0

I created a project with the ibexpert, does the commit correctly, but at the time of turning the Procedure, get the bug:

Multiple Rows in Singleton select.

My intention is to list all values in the city column of the target table. When I run select in a query normal, it returns all values of the column, just does not do the same in Procedure, being that I’m running the same way.

Follow the code below:

create or alter procedure VER_TODOS_DEST  
returns (CIDADES char(20))  
as  
begin  
  select cidade from destino  
  into :cidades;  
  suspend;  
end
  • into :cities doesn’t mean you’re playing the value on the variable? so you can not put more than 1 line in a variable, remove the line into and test.

1 answer

0

Within a procedure or trigger the command select can only return 1 record.

To do what you want you need to use for select as below.

create or alter procedure VER_TODOS_DEST
returns (
    CIDADES char(20))
as
begin
  for
      select
          CIDADE
      from
          DESTINO
      into
          :CIDADES
  do
    suspend;
end
  • @Fabrício Gustavo If the answer was useful to you, if you can mark it as accepted , so when other users view your question they will see that you already have a correct answer and accept it for you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.