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: Returning the largest value from a cursor

Re: Returning the largest value from a cursor

From: Romeo Olympia <rolympia_at_hotmail.com>
Date: 6 Oct 2004 18:34:34 -0700
Message-ID: <42fc55dc.0410061734.4935ad57@posting.google.com>


Let me first see if I understand what you're trying to do. You just rewrote the original CURSOR declaration to add the MAX() function? That's it?

If so, the error you're getting is most probably because you didn't give the max() part of your select an alias. Something like:

CURSOR LastActivityCursor (cin_fk_job INTEGER) is  select max(o.unique_id) max_unique_id
 FROM homs.t_objects o
 where o.Fk_Job = cin_fk_job
 and o.type = 'ACTIVITY'
 and o.status_id = 1;

Here, you will need to refer to that max() value as MAX_UNIQUE_ID.

Hth.

Sean Byrne <byrne_sean_spamtrap_at_hotmail.com> wrote in message news:<ck1c98$51i$1$8300dec7_at_news.demon.co.uk>...
> Hi,
>
> Newbie question:
>
> I have the following cursor for which I wish to return only the largest
> unique_id at one stage of my PL-SQL.
>
> CURSOR LastActivityCursor (cin_fk_job INTEGER) is
> select o.unique_id
> FROM homs.t_objects o
> where o.Fk_Job = cin_fk_job
> and o.type = 'ACTIVITY'
> and o.status_id = 1;
>
> If I rewrite the cursor to do:
> select MAX(o.unique_id)...
>
> when I try and use c_rec1.unique_id later in the script it barfs with:
> ORA-06550: line 52, column 44:
> PLS-00302: component 'UNIQUE_ID' must be declared
>
> What am I doing wrong?
>
> Cheers,
> Sean
Received on Wed Oct 06 2004 - 20:34:34 CDT

Original text of this message

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