Re: proplem writing function in PL/SQL

From: Reginald W. Bailey <rwbailey_at_usa.net>
Date: 1996/10/07
Message-ID: <01bbb4aa$9ae79990$4b4e8486_at_rbailey>#1/1


Sir:

One solution is to change your select statement into a cursor and pass the field name parameter to the cursor.
Or modify the select statement to check the value of the field name with the appropriate data dictionary table to get the column name of the table.

Another is to use the DBMS_SQL (in Oracle 7.2 and above) package and a choice of functions/and or procedures like VARIABLE_VALUE, BIND_VARIABLE, COLUMN_VALUE or DEFINE_COLUMN. The DBMS_SQL package implements dynamic PL/SQL. I hope this helps.

RW Bailey_at_usa.net

mwest_at_hort.cri.nz wrote in article <32532204.0_at_news.palm.cri.nz>...
> 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?????????
>
>
  Received on Mon Oct 07 1996 - 00:00:00 CEST

Original text of this message