Coat
Coat

Reputation: 717

For Loop With Object Table?

Say an object with some functions etc. defined on it and I have a table like

CREATE TABLE person_obj_table OF person_typ;

Now I want to use a for loop to iterate through the table like so

  for x in (select value(t) from person_obj_table t where lastName = 'Smith') loop
    dbms_output.put_line(x.get_fullName);
  end loop;

This seems to fail though as x is not recognized as a person_typ. Any clue about what to do here?

Upvotes: 1

Views: 68

Answers (1)

Lukas Eder
Lukas Eder

Reputation: 221106

Give the value(x) expression a name v, and then use that name:

for x in (select value(t) v from person_obj_table t where lastName = 'Smith') loop
  dbms_output.put_line(x.v.get_fullName);
end loop;

Upvotes: 2

Related Questions