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 -> Re: Oracle Sequence UserFx issue

Re: Oracle Sequence UserFx issue

From: Gert De Neve <Gert.deneve'_at_ping.be>
Date: 5 May 1998 20:22:57 GMT
Message-ID: <01bd7863$00798020$47074ac1@gdeneve>


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

Original text of this message

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