Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Function Error

Xuehan XuJul 11 2014 — edited Jul 11 2014

Hi, everyone

Here is my function:

create or replace function get_road_brief_by_id(id number)

return road_brief_tab as

  iden number(6,0);

  Name char(200);

  Code  char(200);

  tab road_brief_tab := road_brief_tab();

  cursor cur is select "ID", "Name", "Code" from XUXUEHAN."tbl_Road" where "ID" = id;

begin

  open cur;

  LOOP

    fetch cur into iden, Name, Code;

    tab.extend;

    tab(tab.count) := road_brief(iden, Name, Code);

    exit when cur%NOTFOUND;

  END LOOP;

 

  return tab;

end;

I intend to select only those records with "ID" equal to the paramter id. However, when I call it, it returns all the records.  Where did I go wrong?

Thanks

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 8 2014
Added on Jul 11 2014
4 comments
160 views