Re: How to use sequence in a different way

From: Yves Roy, IPA <yvesroy_at_cips.ca>
Date: 31 Aug 98 21:49:52 GMT
Message-ID: <01bdd529$bad07140$437acdcd_at_sctrnt1>


Maadhavan,

Create a function called: get_sequence

that would return a number. Inside it should take the date, format it and concatenate an Oracle sequence to it.

ex.

create or replace
function get_sequence return number
is

     the_sequence number;
begin

   select to_number(to_char(sysdate,'YYYYMMDDHH24MISS'))

                   ||  Myseq.nextval

   into the_sequence
   from dual;
return (the_sequence);
end;
/

Note: you must use a select from dual for the sequence.

        Myseq is your oracle sequence.

ex. of result:

SQL> r
  1* select get_sequence from dual

               GET_SEQUENCE


            199808311748363

i.e. 1998/08/31 17:48:36 plus sequence # 3.

        and so on....
SQL> r
  1* select get_sequence from dual

               GET_SEQUENCE


            199808311751284

SQL> r
  1* select get_sequence from dual

               GET_SEQUENCE


            199808311751295

Bye,
YvesRoy from Montreal
yroy_at_sctr.net

Let me know if it helped !

maadhav_at_yahoo.com wrote in article <6s6f0m$en3$1_at_nnrp1.dejanews.com>...
> Hi anybody
> I have to create a sequence which when used by me either in my
application or
> in my stored procedure should be able to store in todays date and time
within
> the sequence number when ever it is used.
> Example 1008281029....
> Can anybody help me with the syntax.
> It will be of great help.
> Thanks in advance.
>
> maadhavan
>
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
>
Received on Mon Aug 31 1998 - 23:49:52 CEST

Original text of this message