Re: proplem writing function in PL/SQL

From: John Strange <jstrange_at_imtn.dsccc.com>
Date: 1996/10/03
Message-ID: <530adr$mvn_at_camelot.dsccc.com>#1/1


Your are correct. MAX is returning the largest value of field_names.

Try using select count (field_names).
This is assuming field_names is a NOT NULL column. If field_names can be null, use "select count (rowid)"

mwest_at_hort.cri.nz wrote:
: I have to following PL/SQL function:
 

: FUNCTION NewVisitID (field_names IN varchar2)
: RETURN number
: IS
: next_ID number;
 

: BEGIN
: select max(field_names) into next_ID from MIS.VISIT;
: next_ID := next_ID + 1;
: return(next_ID);
: END;

: I want the function to read in a field_name, run the select statement and
: return the max +1 number.
 

: I think the problem is that the select is trying to get the max of what i
: put into field_names rather than the max of the column specified in
: field_names. Can anyone provide a solution?????????

--
This posting represents the personal opinions of the author. It is not the
official opinion or policy of the author's employer. Warranty expired when you
opened this article and I will not be responsible for its contents or use.
Received on Thu Oct 03 1996 - 00:00:00 CEST

Original text of this message