| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> Re: Oracle Sequence UserFx issue
Check in the SQL Reference book for the behavior of the decode function
when you use values of different types in the decode(...).
There you may find the solution.
GDN
drpaner_at_intrex.net wrote in article <6inr4f$bju$1_at_nnrp1.dejanews.com>...
> I have created a small sequence (submeter_seq) that I would like to call
for
> the NEXTVAL through a function. The plan is to pass in a string of the
table
> name, and then through a DECODE statement call the proper Oracle sequence
for
> the passed table and return a new primary key value.
>
> Everything I have tried cannot make this function work when called as:
> SELECT get_next_key ('tablename') from Dual;
>
> I consistantly receive the message:
> SELECT GET_NEXT_KEY ('submeter') from DUAL
> *
> ORA-00902: invalid datatype
>
> Any insight into this situation would certainly be appreciated!
> Thank you,
> Daniel
>
> -------------
> CREATE OR REPLACE FUNCTION get_next_key(for_table IN CHAR)
> RETURN INT
> IS
> next_key INT;
> BEGIN
> SELECT DECODE(for_table, 'submeter', submeter_seq.CURRVAL)
> INTO NEXT_KEY FROM DUAL;
> RETURN (next_key);
> END;
> --------------
>
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/ Now offering spam-free web-based newsreading
>
Received on Tue May 05 1998 - 15:22:57 CDT
![]() |
![]() |