Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: deleting a row from a varray

Re: deleting a row from a varray

From: Martin Buchan <bm901_at_gre.ac.uk>
Date: Thu, 15 Nov 2001 23:04:47 -0800
Message-ID: <3BF4BA8F.5D54BBF8@gre.ac.uk>

thanks for the reply.

Its still not working though. What i get now is:

92/5 PLS-00306: wrong number or types of arguments in call to 'DELETE'

do i still need the where clause? (At present im not using it cos it doesn't look to me as though i would need it with that statement) self.luggage.delete(i)

?

Any more help much appreciated

Thanks
Martin

Jonathan Lewis wrote:

> self.luggage.delete(i) should do what you want.
>
> By the way, MEMBER functions had an implicit
> SELF parameter as the first parameter, so you may
> get some funny side-effects by declaring a SELF
> parameter explicitly.
>
> I assume you are aware that the loop ought
> to be from self.luggage.first to self.luggage.last,
> and you may have to trap exception NO_DATA_FOUND
> if elements of the array are missing.
>
> --
> Jonathan Lewis
> http://www.jlcomp.demon.co.uk
>
> Host to The Co-Operative Oracle Users' FAQ
> http://www.jlcomp.demon.co.uk/faq/ind_faq.html
>
> Author of:
> Practical Oracle 8i: Building Efficient Databases
>
> Screen saver or Life saver: http://www.ud.com
> Use spare CPU to assist in cancer research.
>
> Martin Buchan wrote in message <3BF36BA5.75194F62_at_gre.ac.uk>...
> >HI all,
> >
> >can anyone help me with this?
> >What im trying to do is delete a row from the varray if certain
> >conditions are met. i.e. if a player wants to eat an apple and he has
> >one in his luggage array then, eat it (delete the row) and update his
> >life points. Simple huh...
> >
> >I have a root object (player_type) with a varray (luggage_type) inside
> >
> >it, and a table of object type player_type. Here is a snippet of code
> >from my object declaration:
> >
> >create or replace type player_type as object (
> >p_name varchar2(25),
> >life_points number(2),
> >...
> >luggage luggage_type_array,
> >...)
> >...
> >MEMBER FUNCTION eatFood (self in out player_type, food varchar2) RETURN
> >Number,
> >PRAGMA RESTRICT_REFERENCES (eatFood, WNPS, RNPS))
> >/
> >heres my code for the eatFood method so far. I hope some of this makes
> >sense to some of you :-)
> >
> >MEMBER FUNCTION eatFood (self in out player_type, food varchar2) RETURN
> >number
> >IS
> > flag integer := 0;
> > temp number := 0;
> > health number(2);
> > i integer;
> >BEGIN
> >
> > for i in 1..2 loop
> > if (self.luggage(i) is not null) then
> > if (self.luggage(i).l_name = food) then
> > health := self.luggage(i).health_bonus;
> > delete from self.luggage *<<<<PROBLEM
> >LINE***************
> > where self.luggage(i).luggage_name = food;
> > flag := 1;
> > end if;
> > end if;
> >end loop;
> >if (flag = 1) then
> > self.life_points := self.life_points + health;
> > return1;
> >else
> > return 0;
> >end if;
> >END;
> >
> >
> >The error i get is:
> >
> >100/5 PL/SQL: SQL Statement ignored
> >100/17 PLS-00201: identifier 'SELF.LUGGAGE' must be declared
> >
> >Anyone any ideas?
> >
> >thanks in advance
> >
> >Martin
> >
> >
> >
Received on Fri Nov 16 2001 - 01:04:47 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US