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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Pl/sql newbie question....

Re: Pl/sql newbie question....

From: Karsten Farell <kfarrell_at_medimpact.com>
Date: Fri, 04 Oct 2002 19:55:33 GMT
Message-ID: <Vmmn9.719$W83.60950778@newssvr13.news.prodigy.com>


smenard_at_avior.com wrote:
> What is the best way to implement the column count when i insert a new
> row in this table...?

For one thing, 'count' is a very poor choice for a column name. Unless you want to hardcode every value of 'inv_id' in your cursor, you need to pass an argument to the cursor containing the required value of inv_id (perhaps from another cursor or loop).

Maybe something like:

cursor test_cur (in_inv_id in inv_id%type) is

   select max(count_column_name)
   from inv
   where inv_id = in_inv_id
   for update of count_column_name;
...
open test_cur (whatever_value_of_inv_id_required); fetch test_cur into nb_count;
insert into inv values(

   whatever_value_of_inv_id_required,
   nb_count+1,...);
close test_cur;

...[plus any other processing required]... Received on Fri Oct 04 2002 - 14:55:33 CDT

Original text of this message

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