Re: Creating sequences.

From: Chuck Hamilton <chuckh_at_ix.netcom.com>
Date: 1996/02/27
Message-ID: <313315e2.1934183_at_nntp.ix.netcom.com>#1/1


carver_at_frodo.okcu.edu (Lance Carver - Oklahoma City University) wrote:

>Hello,
>
> I am trying to reinitialize a sequence number, depending on the change
>of a date. The following is the code I am using, however it keeps erroring
>out on the select statement. Can anyone help???
>
>create sequence job_sequence_num
> increment by 1
> maxvalue (select distinct job_num_yy||job_num_mm||job_num_dd
> from job_log_tbl
> order byh job_num_yy||job_num_mm||job_num_dd;)
> minvalue 1
> cycle;

I don't think that's a legal syntax. Even if it were, you'd want a single value for the maxvalue yet your returning a sorted result set. I'm assuming you want the max yymmdd from the select.

try something like this (standard untested code disclaimer applies)...

set feedback off
set pages 0
spool crseq.sql
column x1 format a80
select

  'create sequence job_sequence_num' x1,
  '  increment by 1' x1,
  '  maxvalue '||max(job_num_yy*10000+job_num_mm*100+job_num_dd) x1,
  '  minvalue 1' x1,
  '  cycle;'

from
  job_log_tb1;

spool off
set pages 24
_at_crseq

--
Chuck Hamilton
chuckh_at_ix.netcom.com

If at first you don't succeed, skydiving isn't for you.
Received on Tue Feb 27 1996 - 00:00:00 CET

Original text of this message