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

Home -> Community -> Usenet -> c.d.o.server -> Oracle Sequence UserFx issue

Oracle Sequence UserFx issue

From: <drpaner_at_intrex.net>
Date: Tue, 05 May 1998 15:00:15 -0600
Message-ID: <6inr4f$bju$1@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 - 16:00:15 CDT

Original text of this message

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